How to change aggregation $group, which returns null when $lookup'e empty array?

Good afternoon/evening
Faced with the SL. situation.

In General:
A collection of "recommendations", it is the entry of SL. types:

{
 "_id" : ObjectId("5c995106deafcc7c86b9f284"),
 "id" : 777,
 "name" : "developers",
 "likesPeople" : [ 
 { "id" : 579 }, 
 { "id" : 398 }
]
}

When I run $lookup with a collection of users by ID in the array schnick recommendations.likesPeople (seq. way):

db.getCollection('recommendations').aggregate([
 { $match: { id: 777 }},
 { $unwind: "$likesPeople" },
 { $lookup: {
 from: "users",
 localField: "likesPeople.id"
 foreignField: "id",
 as: "likesPeople"
 } },
 { $unwind: "$likesPeople" },
 { $group : { 
 _id: '$_id',
 likesPeople: { $push: "$likesPeople"},
 id: { $first: '$id' }
}
}
])

Get the result:

{
 "_id" : ObjectId("5c995106deafcc7c86b9f284"),
 "id" : 777,
 "likesPeople" : [ 
{
 "_id" : ObjectId("5c99500adeafcc7c86b9f283"),
 "id" : 579,
 "name" : "Bob"
 }, 
{
 "_id" : ObjectId("5c99b429deafcc7c86b9f28b"),
 "id" : 398,
 "name" : "Mary"
}
]
}

The problems startwhen the array likesPeople recommendations in the collection - empty:

{
 "_id" : ObjectId("5c995106deafcc7c86b9f284"),
 "id" : 777,
 "name" : "developers",
 "likesPeople" : []
}

After executing $lookup/$group, I get an empty result and in consequence lose the ability to get all other fields ( _id, id, name ). To some extent this is logical...

The question: What needs to change in mongodb query that would be in cases when likesPeople in the collection has no values (empty), the result gave me all the other fields:

{
 "_id" : ObjectId("5c995106deafcc7c86b9f284"),
 "id" : 777,
 "name" : "developers",
 "likesPeople" : null // or whatever
}
March 19th 20 at 09:51
0 answer

Find more questions by tags MongoDB