From what I saw in the example the _id
does not have a link:
If you have a link you can do a lookup in the collection Usuario
instead of the project, I did on top of the result you put as an example
You can do this:
db.login.aggregate([
{
$match: {
'Login': 'admin',
'Senha': '12345',
}
},
{
$project :{
login: db.login.distinct('Usuarios.Login', { 'Usuarios.Login': 'andre' }),
senha: db.login.distinct('Usuarios.Senha', { 'Usuarios.Login': 'andre' }),
}
},
{ $unwind: { 'path': '$login', 'preserveNullAndEmptyArrays': false } },
{ $unwind: { 'path': '$senha', 'preserveNullAndEmptyArrays': false } },
{
$match: {
'login': 'andre',
'senha': '17344',
}
}
])