As I embarked on my journey of creating my first Meteor app, I encountered a challenge that left me feeling a bit lost. I have a collection of Entries and I want to categorize them by date, not simply sort them. Each entry comes with a date and I envision building a timeline-like structure. Here's an example of what one of the entries looks like:
{
"_id": "xHmfEc5gMmGzDZgD2",
"title": "something",
"labels": [
"pv4LnWNheyYRJqG7D"
],
"images": [
"zitE3FwmesHsNCxGG",
"kYQTJYApDxPr4sMdW",
"4enopyawfqBXRDvuh"
],
"author": "TMviRL8otm3ZsddSt",
"createdAt": "2016-01-31T21:05:55.401Z",
"date": "2016-01-31T21:05:55.401Z",
"description": "description"
}
Ultimately, I aim to create a timeline where entries are grouped by days. Here's a glimpse of what the timeline could look like, with entries categorized by day:
Day - 11.02.2016
entry - xHmfEc5gMmGzDZgD2
entry - ZhmfEc5gMmGzDZg8z
entry - uafEc5gMmGzDZgD25
Day - 12.02.2016
entry - xHmfEc5gMmGzDZgD2
entry - ZhmfEc5gMmGzDZg8z
Day - 17.02.2016
entry - xHmfEc5gMmGzDZgD2
entry - ZhmfEc5gMmGzDZg8z
entry - xHmfEc5gMmGzDZgD2
entry - ZhmfEc5gMmGzDZg8z
Instead of creating a separate collection for a calendar, I would like to extract the days directly from the entries. Is there a way to accomplish this without making separate DB queries for each day?
I'm currently thinking of storing all the different dates from the entries in a separate collection and then having each day query the entries collection to fetch the relevant ones. However, I feel like this approach might not be efficient, as it would involve a DB query for each day...