I have a collection which contains some documents as follows,
{
"transactionId": 3432423,
"reviews": [
{
"fromUser": {
"userId": "eu-central-1:-4e37-ad56-5236aa1acd6e"
},
"toUser": {
"userId": "eu-central-1:8e4934bb-7533-4e0d-9f78-0ec8db9544cc"
},
"rating": 4.3,
"comment": "good listing"
},
{
"toUser": {
"userId": "eu-central-23e-4e37-ad56-5236aa1acd6e",
"email": "yourlife@gmail.com",
"firstName": "your",
"lastName": "life"
},
"fromUser": {
"userId": "eu-central-133-4e0d-9f78-0ec8db9544cc",
"email": "mylife@gmail.com",
"firstName": "my",
"lastName": "life"
},
"rating": 4.3,
"comment": "bad listing"
}
]
}
i need to check if subdocument reviews present inside the document. i have used this query,
db.getCollection('_testCollection').find({ "$elemMatch": { "reviews": { "$exists": false } }})
it throws an error saying,
"errmsg" : "unknown top level operator: $elemMatch",
via Sajeetharan
No comments:
Post a Comment