Hello,
I was wondering if when we use project to edit fields, are they edited as a “view” just in the query or are they edited permanently in the database ?
This part is correct:
The database is not modified.
How about add fields ? Does it add in the database ?
Nope. To write out of the pipeline to a database see $out
or $merge
You can also export the result of a query straight from mongoexport
or mongodump
, which is great.
@Rym_Bouchetara, you can use $addFields
(or its alias $set
) aggreagtion stage in an Update with an Aggregation operation and update the data to the database.