$project and $addFields
Reshape documents.
Example
db.users.aggregate([
{ $project: { name: 1, year: { $year: "$born" } } },
{ $addFields: { adult: { $gte: ["$age", 18] } } }
])Exercise
Add a field.
{ : { x: 1 } }
Quiz Test
These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.