I have two collections in my mongoDb database, one called media, one called users.
Documents in the media collection:
{"_id":{"$oid":"6379204a8cf5677554c26c1b"},"_partition":"6378eb74f6613d5d4192da79","name":"silas test"}
{"_id":{"$oid":"6378eb74f6613d5d4192da79"},"_partition":"6378eb74f6613d5d4192da79","name":"test media"}
Document in the users collection:
{
"_id":{
"$oid":"6379ee6c770a8f43afc8e3e4"},
"_partition":"6378eb74f6613d5d4192da79",
"types":[
{
"mediaReference":[
{"$oid":"6379204a8cf5677554c26c1b"}
],
"mediatype":"podcast"
},
{
"mediaReference":[
{"$oid":"6378eb74f6613d5d4192da79"}
],
"mediatype":"movie"
}
],
"username":"silas"
}
Now im looking for a way to use the mongoDb aggregation pipeline to get the following result:
{
"_id":{
"$oid":"6379ee6c770a8f43afc8e3e4"},
"_partition":"6378eb74f6613d5d4192da79",
"types":[
{
"mediaReference":[
{
"_id": {
"$oid":"6379204a8cf5677554c26c1b"
},
"_partition":"6378eb74f6613d5d4192da79",
"name":"silas test"
}
],
"mediatype":"podcast"
},
{
"mediaReference":[
{
"_id": {
"$oid":"6378eb74f6613d5d4192da79"
},
"_partition":"6378eb74f6613d5d4192da79",
"name":"test media"
}
],
"mediatype":"movie"
}
],
"username":"silas"
}
Basically im searching for a way to paste the refferenced document into the mediaReference object inside the users document.
i would appreciate any help