So I have this data structure below; it is basically a calendar of events that is set for an institution.
{
"_id" : ObjectId("58485e8b630c3106ba4af558"),
"institutionId" : "6z66TRkvmEpCkLsKH",
"events" : [
{
"name" : "Christmas Day",
"date" : ISODate("2016-12-25T21:21:11.874Z"),
"holiday" : true
},
{
"name" : "Independence Day",
"date" : ISODate("2016-08-04T21:21:11.874Z"),
"holiday" : true
},
{
"name" : "My Birthday",
"date" : ISODate("2016-06-20T21:21:11.874Z"),
"holiday" : false
}
],
"createdAt" : ISODate("2016-12-07T19:10:03.351Z")
}
How do I get the array of just the holidays? (where holiday = true)
[
{
"name" : "Christmas Day",
"date" : ISODate("2016-12-25T21:21:11.874Z"),
"holiday" : true
},
{
"name" : "Independence Day",
"date" : ISODate("2016-08-04T21:21:11.874Z"),
"holiday" : true
}
]
Is this even the right approach at storing calendar events for an institution or should I have one event per document?
Thanks!