mongo project code example
Example 1: mongodb project
{ $project: { "contact.address.country": 1, contact: 1 } }
Example 2: mongodb project all fields
db.collection.aggregate([
{ "$addFields": { "custom_field": "$obj.obj_field1" } }
])
{ $project: { "contact.address.country": 1, contact: 1 } }
db.collection.aggregate([
{ "$addFields": { "custom_field": "$obj.obj_field1" } }
])