from doc:
The $addFields stage is equivalent to a $project stage that explicitly specifies all existing fields in the input documents and adds the new fields.
But if I write:
db.projects.aggregate(
{
$project: {
count: 1
}
}
)
This code doesn't add count to the result.
In contrast:
db.projects.aggregate(
{
$addFields: {
count: 1
}
}
)
This adds count field to result.
How to add new field to result using $project? I think it is possible because it is equivalent.