What is the best way to perform a lookup and combine it with the object that is used for the lookup?
For example, I have collection 1 that is the following format:
{
_id:ObjectID("xxxxxxxx"),
id: "12345",
name: "name xyz",
goal: "goal 123",
start: null,
end: null,
plan:[
{
day: 0,
exercises:[
{
id: "xxxx1",
stat1: "stat 1 stuff",
stat2: "stat 2 stuff"
},
{
id: "xxxx2",
stat1: "stat 1 stuff",
stat2: "stat 2 stuff"
}
]
},
{
day: 1,
exercises:[
{
id: "xxxx2",
stat1: "stat 1 stuff",
stat2: "stat 2 stuff"
}
]
}
]
}
and I have collection 2 (exercises) which is the following format:
{
_id: ObjectID("yyyyyy"),
id: "xxxx1",
stat3: "stat 3 stuff",
stat4: "stat 4 stuff"
},
{
_id: ObjectID("yyyyyy"),
id: "xxxx2",
stat3: "stat 3 stuff",
stat4: "stat 4 stuff"
}
Is there a way to perform a lookup and get results in the following format:
{
_id:ObjectID("xxxxxxxx"),
id: "12345",
name: "name xyz",
goal: "goal 123",
start: null,
end: null,
plan:[
{
day: 0,
exercises:[
{
id: "xxxx1",
stat1: "stat 1 stuff",
stat2: "stat 2 stuff",
stat3: "stat 3 stuff",
stat4: "stat 4 stuff"
},
{
id: "xxxx2",
stat1: "stat 1 stuff",
stat2: "stat 2 stuff",
stat3: "stat 3 stuff",
stat4: "stat 4 stuff"
}
]
},
{
day: 1,
exercises:[
{
id: "xxxx2",
stat1: "stat 1 stuff",
stat2: "stat 2 stuff",
stat3: "stat 3 stuff",
stat4: "stat 4 stuff"
}
]
}
]
}