Answer the question
In order to leave comments, you need to log in
How to query in MongoDB query results?
Hello.
I read a lot of things, but there was no understanding, and no. And the request is very popular.
Step1: Get a list of guids of all organizations with the specified conditions
db.organizations.find({
docStatus: {
$ne: "delete"
},
isAuthorized: true
}, {
_id: 0,
guid: 1
})
db.users.find({
org:"guid_из_шаг1", active:true
})
Answer the question
In order to leave comments, you need to log in
db.users.aggregate({$match: {active:true}},
{$lookup:
{ from: "org", localField: "org.id", foreignField: "guid", as: "org"},
{$unwind: "$org"},
{$match: {"org.docStatus": {$ne: "delete"}, "org.isAuthorized": true},
{$group: { _id: "$_id"}})
https://docs.mongodb.com/manual/reference/operator...
https://docs.mongodb.com/manual/reference/operator...
https://docs.mongodb.com/manual/reference/ operator...
In general, Monga is not intended for this... You need to choose a database for the task, and not follow the fashion...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question