Answer the question
In order to leave comments, you need to log in
Sampling documents with subdocument filtering?
Good day.
There is a collection of documents, each document of which has an array of nested documents.
Subdocuments have the archived/deleted status.
The task is to select documents so that they do not show nested documents in the archive/deleted status.
Is it possible to do this with a single request to mongo, or will I have to filter nested documents at the application level?
Thank you!
UPD:
I'll add an example to make it clearer.
There is such a document.
{
"name": "Doc1",
"messages": [
{
"title": "Mes1",
"archive": false
},
{
"title": "Mes1",
"archive": true
}
]
}
{
"name": "Doc1",
"messages": [
{
"title": "Mes1",
"archive": false
}
]
}
Answer the question
In order to leave comments, you need to log in
db.documents.find({"abarchive": 0})
Can be done in one query. Transition by nesting through dots.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question