I need to perform an aggregation with time, using mongodb go driver + golang
I have the following document: Task {_id, person, cycle, date}.
I need to know the number of tasks per cycle in the hour interval.
Ex:
Task 1 - {Id: XXXX, person: AAA, cycle: 1, date: 2021-02-03T13: 57: 25.590 + 00: 00}
Task 2 - {Id: XXXX, person: AAA, cycle: 1, date: 2021-02-03T13: 58: 25.590 + 00: 00}
Task 3 - {Id: XXXX, person: AAA, cycle: 1, date: 2021-02-03T14: 58: 25.590 + 00: 00}
Task 4 - {Id: XXXX, person: AAA, cycle: 2, date: 2021-02-03T13: 57: 25.590 + 00: 00}
Task 5 - {Id: XXXX, person: AAA, cycle: 2, date: 2021-02-03T14: 57: 25.590 + 00: 00}
I need the result like this:
cycle 1 - between 13 and 14 - two tasks
cycle 1 - between 14 and 15 - a task
cycle 2 - between 13 and 14 - a task
cycle 2 - between 14 and 15 - a task
Can you help me?