I'm looking to create a timeline REST api which will pull MongoDB data entries and organize them using a created_at property that I have in the collection.
I'm looking to separate the "timeline" entries by a few different groupings.
The first grouping will be "last 24 hours", the second grouping will be "yesterday", the third grouping will be "last week", and the final grouping will be "everything else". I will limit the "everything else" so it doesn't pull a bunch of things from a long time ago...
What I'm doing in Mongoose is a MongoDB $group to group by my created_at, but I'm having a problem because I simply want to do a created_at "like" because I can't use the exact timestamp or the grouping won't work.
Does anyone have any experience with something similar? I'd how can this be expanded to use multiple groupings where I can first group by "today" (last 24 hours) and then group everything else by week or "last week"?
I need to first do a group, then exclude the previous grouped results in my next grouping.
Thanks for your time.