Skip to content

Instantly share code, notes, and snippets.

@johnlpage
Created March 17, 2022 09:34
Show Gist options
  • Save johnlpage/8b6b4f914d5762c000f4eed6d8687746 to your computer and use it in GitHub Desktop.
Save johnlpage/8b6b4f914d5762c000f4eed6d8687746 to your computer and use it in GitHub Desktop.
[
{ $match: { type: "electric" } },
{ $unwind: "$devices" },
{ $match: { "devices.watts": { $gt: 0 } } },
{ $setWindowFields: { sortBy: { date: 1 }, partitionBy: "$devices.name",
output: { totalUsage: { $integral: { input: "$devices.watts", unit: "hour" } } } }},
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment