I have a mongoose schema of RoomSchema like below
{
.....
venue_details : {type: Schema.ObjectId, ref: 'VenueDetail'}
.....
}
When I'm searching with one of the ObjectIds that I am having with me in mongodb system console it is giving correct result for below query.
db.rooms.find({venue_details: "576a6aa52edadbba50ff0944"})
But whne I'm searching inside the mongoose. I'm getting an empty array.
Room.find({venue_details: new ObjectId("576a69c32edadbba50ff093e")},function(err, docs){
if(err){
console.log(err);
}else{
console.log(docs);}
})
I've tried putting ObjectId = mongoose.Types.ObjectId
, also ObjectId = mongoose.Schema.ObjectId
, and also ObjectId = mongoose.Schema.Types.ObjectId
Even tried just putting String in the place of new ObjectId("576a69c32edadbba50ff093e")
just like "576a69c32edadbba50ff093e"
. Even it is not working.
I'm using mongoose V 4.4.1, and MongoDB V 3.2.7