I just want to add a new field through $project
pipeline and let the other properties to slip through for further processing, I know that you can do this :
db.people.aggregate([
{$project: {name: 1, address: 1, birth_month: {$month: "$birthdate"}}}
])
But with more and more complex document, I have a great difficulty to write 20++ field name in $project
. Can I just add a field through aggregation pipeline in such a way that I don't have to specified other field one by one, something like
db.people.aggregate([
{$appendField: {birth_month: {$month: "$birthdate"}}}
])