skip to Main Content

Mongodb – How can I project an object only if a specific field exists?

I have the following documents in my MongoDB Aggregation stage: _id: ObjectId('641316fd596514e63a2121ca'), teamId: 5, playerId: ObjectId('64131139596514e63a2121c1') _id: ObjectId('641316fd596514e63a2121ca'), teamId: 5, playerId: ObjectId('64143f7702ede13fea5ff3be') _id: ObjectId('64143f458b6a6cf54652d3a5'), teamId: 17, playerId: ObjectId('64143fa75a97b9a63a260e16') _id: ObjectId('64143f4f9ba5f2b3cf3030e6'), teamId: 3 I want to create an Object field called…

VIEW QUESTION
Back To Top
Search