I have 2 collection coll1 and coll2. I want to apply $lookup on fields "_id" and "comm_field" so I used the query:
db.coll1.aggregate([
{
$lookup:
{
from: "coll2",
localField: "_id",
foreignField: "comm_field",
as: "inventory_docs"
}
},
{
$project:{"_id" : 0, "inventory_docs" : 1}
},
{ $unwind:"$inventory_docs"}
])
And get the output as:
/* 1 */
{
"inventory_docs" : {
"_id" : ObjectId("ssdfsfsdfsdfsfsdfsdfsdfsfsdf"),
"comm_field" : NumberLong(1111),
"status" : "active"
}
}
/* 2 */
{
"inventory_docs" : {
"_id" : ObjectId("erteterterterterterterterter"),
"comm_field" : NumberLong(1111),
"status" : "active"
}
}
/* 3 */
{
"inventory_docs" : {
"_id" : ObjectId("vbvbfvbdbbcvbvcbcdrgvbcbcbcv"),
"comm_field" : NumberLong(2222),
"status" : "active"
}
}
Is there any way by which i can see the output like:
{
"_id" : ObjectId("ssdfsfsdfsdfsfsdfsdfsdfsfsdf"),
"comm_field" : NumberLong(1111),
"status" : "active"
}
{
"_id" : ObjectId("erteterterterterterterterter"),
"comm_field" : NumberLong(1111),
"status" : "active"
}
{
"_id" : ObjectId("vbvbfvbdbbcvbvcbcdrgvbcbcbcv"),
"comm_field" : NumberLong(2222),
"status" : "active"
}
So basically I want my output in format {---}, not in {"inventory_docs":{---}}