$project assign value of gravity.value to gravity

Chapter 1: Shaping docuements with Project:

An example was given where “gravity” is assigned the value of gravity.value but it was explained in the video that we were “RE-ASSIGNING” the value of “gravity” so does this mean that we changed the structure of the entire db so that gravity no longer equaled gravity.value? Did this $project operator demolish gravity.value forever? Or did the video not explain that a new field name was being created as “gravity?” I’m confused. Was the value of gravity re-assigned temporarily or was it permanent? What is the end result to the embedded value named gravity.value?

@Rufel_05530

Once you have projected a field in the pipeline, that is the new value. However, the old value is still available of course in the actual collection, which is not affected. This is pretty much identical to the use of the project() operation in the query language.

Perfect! That’s exactly what I wanted to know. Original documents are preserved. Thanks!