Open
Description
Description
The DB sometimes randomly returns "no documents" when using $elemMatch
in the match.
Setup
Share link: https://mongoplayground.net/p/AylVo0AlDWF
Database type
bson
Database content
[
{
"_id": ObjectId("000000000000000000000111"),
"triggers": [
{
"trigger": "sa",
"method": "liveness_check",
"source": {
"service": "example",
"type": "project",
"identifier": "222222222222222222222222"
}
}
]
},
{
"_id": ObjectId("000000000000000000000222"),
"triggers": [
{
"trigger": "sa",
"method": "liveness_check",
"source": {
"service": "example",
"type": "project",
"identifier": "111111111111111111111111"
}
}
]
},
{
"_id": ObjectId("000000000000000000000333"),
"triggers": []
},
{
"_id": ObjectId("000000000000000000000444"),
"triggers": [
{
"trigger": "sa",
"method": "liveness_check",
"source": {
"service": "example",
"type": "project",
"identifier": "ff"
}
},
{
"trigger": "ff",
"method": "liveness_check",
"source": {
"service": "example",
"type": "project",
"identifier": "222222222222222222222222"
}
}
]
}
]
Query
db.collection.find({
triggers: {
$elemMatch: {
"trigger": "sa",
"method": "liveness_check",
"source": {
"service": "example",
"type": "project",
"identifier": "222222222222222222222222"
}
}
}
})
Expected Result
[
{
"_id": ObjectId("000000000000000000000111"),
"triggers": [
{
"method": "liveness_check",
"source": {
"identifier": "222222222222222222222222",
"service": "example",
"type": "project"
},
"trigger": "sa"
}
]
}
]
Actual Result
Sometimes same as the expected result, sometimes no document found
Metadata
Metadata
Assignees
Labels
No labels
Activity