The example collection I have
{
"_id" : "123",
"name" : "John",
"height": 170,
"favorite" : {
"fruits" : [
{
"name" : "banana",
"reason" : null
},
{
"name" : "orange",
"reason" : null
}
],
}
},
{
"_id" : "456",
"name" : "Cena",
"height" : 160,
"favorite" : {
"fruits" : [
{
"name" : "berry",
"reason" : null
},
{
"name" : "orange",
"reason" : null
}
],
}
}
The array value I get from JS is ["banana","orange"]
, I join them become banana,orange
and pass it for matching. It must exactly match all the value from the collection and the return value should be the "_id":"123"
, if the value is banana,orange,berry
result should be NONE.
I tried the Matches
string q_value = "banana,orange"; // exmaple
IMongoQuery query = Query.And(
Query.GTE("height",170),
Query.Matches("favorite.fruits", q_value)
);
MongoCursor mongocursor = db.GetCollection("XXDB", "Member").Find(query);
But I think Matches
is not the one I'm looking for.
This How to check if an array field contains a unique value or another array in MongoDB? maybe is the way, but it is not query method, in this question the query I looking for is just one of the query in my function.
Help me if anyone know the query method, THANKS A LOT