I've got the following schema:
var invitationSchema = new Schema({
emailAddress : String
});
var eventSchema = new Schema({
name : String,
start_date : Date,
end_date : Date,
venue : { type : Schema.ObjectId, ref : 'Venue' },
invitees : [invitationSchema]
});
Which seems fine to me...?
I'm trying to do the following query:
Events.findOne({'invitees._id' :'4f8dcb06ee21783d74000040'}, function(err, myEvent) {
//myEvent is null?
});
myEvent is null, even though, in my Events collection, there is an Event doc, with an array of invitees, one of those, has an id of 4f8dcb06ee21783d74000040.
I read this, which says it should now work?
My fault- Was querying for ObjectID but was stored as string...
Silly me.