'Is there difference between buckets in mongo time series collection and bucket stage in aggregation?

I am confused. My aim is to get data from my collection based on time ranges like data in a day, week and month.

I found almost no implementation for creating a time series collection where I can bucket data liek described in this post.

Time Series Collection

{  "timeField": created_at, "metaField": interaction_type, "expireAfterSeconds": 2592000 } interaction_type: comment OR like OR view

So I want to retrieve count of each interaction type in last 24 hours, last 7 days, last 30 days.

I have it figured out theoretically, if any of you can help please let me know.

I tried creating the time series collection and inserted around a million documents.

I cannot figure out how to proceed at all.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source