Answer the question
In order to leave comments, you need to log in
How to search in Mongo by key and value throughout the document?
Good afternoon.
It is necessary to find all the people who graduated from, for example, institute 567.
The problem is that we cannot accurately specify the parent elements for this institute (and are at different levels).
For example, in professions.actor. theater.drama and professions.actor. stuntman is institute
{
"_id": ObjectId("56ff619b14989a0ed0316921"),
"firstName": "Иван",
"lastName": "Лабанов",
"professions": {
"actor": {
"film": {
"drama": {
"institute": 567
},
},
"theatre": {
"drama": {
"institute": 123,
},
},
"stuntman": {
"institute": 321,
}
},
}
}, {
"_id": ObjectId("56fe77b114989a05577e9f22"),
"firstName": "Петр",
"lastName": "Смирнов",
"professions": {
"actor": {
"film": {
"comedy": {
"institute": 567,
}
},
}
}
}, {
"_id": ObjectId("56fe77b114989a05577e9f11"),
"firstName": "Василий",
"lastName": "Иванов",
"professions": {
"actor": {
"film": {
"comedy": {
"institute": 123,
}
},
}
}
}
Answer the question
In order to leave comments, you need to log in
No way.
You have a strange database structure.
Is it the same person who studied to be a theater comedian and a movie comedian?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question