I have s schema like:
var EntitySchema = new Schema({
name : {type: String, default: null},
organizations : [{
id: {
type: mongoose.Schema.Types.ObjectId,
ref: 'Organization'
}}]
});
I have an id of organization, How can I make a query for Entity.find({}) and find Entity that has this id in its organizations array?
I used this in mongo shell
db.entity.find({"organizations.id": { $in: [ObjectId("ididididididid")]}}).pretty()
and it worked, but it doesn't work in express method, do I do something wrong? Does $in works both ways? I have a feeling that its not what I should be using in this query.
organization: [ { id: ObjectId('hashedvalue44') } ]organizations: [{id: 'hashedvalue44'}, {id: 'hashedvalue55'}], ororganizations: ['hashedvalue44', 'hashedvalue55']either is acceptable as of now.