I want to search a document that contains an array of objects with 2 or more keys on the basis of a single key within the array of objects.
For example I have the following scema-
var empSchema = new Schema({
name : String,
age : Number,
projects : [{id : Schema.Types.ObjectId, name : String}]
});
I want to search all emloyees who worked on project named "Sample Project".
Thanks in advance.
For example I have the following scema-
var empSchema = new Schema({
name : String,
age : Number,
projects : [{id : Schema.Types.ObjectId, name : String}]
});
I want to search all emloyees who worked on project named "Sample Project".
Thanks in advance.
Documentation - http://mongoosejs.com/
Plugins - http://plugins.mongoosejs.com/
Bug Reports - http://github.com/learnboost/
Production Examples - http://mongoosejs.tumblr.com/
StackOverflow - http://stackoverflow.com/
Google Groups - https://groups.google.com/
Twitter - https://twitter.com/mongoosejs
IRC - #mongoosejs
I think the query condition you want is:
{'projects.name': 'Sample Project'}
See relevant Mongo docs:
댓글 없음:
댓글 쓰기