-
Notifications
You must be signed in to change notification settings - Fork 29
Description
First off, this project is awesome.
I have data that looks like this:
courses = [
{
title: "Biology",
assignments: [
{
done: false,
due: "2012-03-05T05:00:00.000Z",
},
{
done: false,
due: "2012-03-05T05:00:00.000Z",
},
{
done: true,
due: "2012-03-06T05:00:00.000Z",
}
]
},
{
title: "Math",
assignments: [
{
done: true,
due: "2012-03-05T05:00:00.000Z",
},
{
done: false,
due: "2012-03-03T05:00:00.000Z",
},
{
done: true,
due: "2012-03-06T05:00:00.000Z",
}
]
}
So basically a collection of courses which have a list of assignments.
I'm using backbone-relational to model this; courses is a QueryCollection, the individual course model is a RelationalModel, and the individual assignment model is a RelationalModel as well.
The query I want to do is to find all of the assignments (in all courses) that are due within a specific range and are not done.
From the examples (and being somewhat familiar with Mongo -- it's what I use on the server) I think that would look like this:
courses.query({
assignments: {
$elemMatch: {
"done": true,
"date": "2012-03-05T05:00:00.000Z"
}
}
});
(I'm just matching one specific date, not a range, for simplicity purposes).
The problem is that the above query does not return anything. It seems as if it's not applying the $elemMatch criteria to the 'assignments' field of each course.
Any idea why that might be? Feel free to call me names if I'm doing something incredibly dumb here -- my brain is a bit fried from staring at my computer all day ;)
Thanks!