I have data in collection in mongodb like this :
[
{
_id : "ObjectId(1)",
name : "data1",
data : [
{ text: "a", value: 1 },
{ text: "b", value: 2 }
]
},
{
_id : "ObjectId(2)",
name : "data2",
data : [
{ text: "b", value: 2 },
{ text: "a", value: 1 }
]
}
]
like you see, data1 and data2 have same data but different order.
I need to find in this db.somecol.find({}) that return all document with same data that ignore order in array.
how to do that?
I try using $elemMatch but it can't.
that return all document with same data- a bit confused by this statement, So do you've any inputs to match with or do we need to scan all documents in collection to get documents which has matching objects indataarray, I guess mostly it's with inputs{ text: "b", value: 2 }, { text: "a", value: 1 }, can you just confirm - Also if it's the case do you need all inputs to exist indataarray or any one object ?