So I have this collection containing a field "weekdays" representing weekdays Monday-Sunday (checked or not checked):
var collection = [
// work week (Monday to Friday)
{
weekdays: [true, true, true, true, true, false, false]
},
// weekend
{
weekdays: [false, false, false, false, false, true, true]
},
// ...
];
Now, how can I query this collection to find all items that has true for a specified weekday?
My first attempt was to use something like this:
// $elemMatch...
'weekdays[0]': true // Monday
But it did not seem to work. I'm out of ideas atm and would appreciate any help!