Hi i want to match in an array of objectIds in mongoose using node js but i got the result in mongo shell but when implement with my code not find any result.
This is my collection.
{
"_id" : ObjectId("59c21ef1a870b05034f2cec1"),
"__v" : 0,
"name" : "Force",
"createdAt" : ISODate("2017-09-20T07:55:29.816Z"),
"updatedAt" : ISODate("2017-09-20T07:55:29.817Z"),
"createdBy" : "599bfa0ee67842000493fefc",
"timestamp" : 1505894129819.0,
"isDeleted" : 0,
"isActive" : 1,
"updatedBy" : "",
"subSegments" : [
ObjectId("59c2172ab500ce0a946aa93a"),
ObjectId("59c21734b500ce0a946aa93b")
],
"segments" : [
ObjectId("59c2166db500ce0a946aa935"),
ObjectId("59c216a5b500ce0a946aa936")
],
"subject" : [
ObjectId("59c2179fb500ce0a946aa93f")
]
}
This is my query :-
Topic.aggregate([
{
$unwind: "$subject"
},
{
$match:{subject: new Mongoose.Schema.Types.ObjectId("59c2179fb500ce0a946aa93f")}
}
]
When i am running this query on mongo shell got result but in my code this query not return any result or error .