I have two collections: Manager and Venue.
Manager document example
{
"_id":"5d4f84dd4c35350b284b08ea",
"Name":"Name",
"Surname":"Surname",
"Username":"Username",
"Password":"123456",
"CreatedDate":"2019-08-11T03:00:44.981Z"
}
Venue document example
{
"_id":"5d4f84de4c35350b284b08eb",
"Name":"Name",
"Manager":"5d4f84dd4c35350b284b08ea",
"CreatedDate":"2019-08-11T03:00:46.598Z"
}
I learned that there are two ways to do inner join
First way
solve this problem in two queries
var manager = db.manager.findOne({"id" : "5d4f84dd4c35350b284b08ea"})
var venue = db.venue.findOne({"id" : manager.id})
Second way
To have everything with just one query using the $lookup feature of the aggregation framework
db.Manager.aggregate(
[
{
$lookup:
{
from: "Venue",
localField: "localField",
foreignField: "_id",
as: "as"
}
},
]
)
here is the question
Second way is more suitable for me but I'm not sure which way to use, can you help me.