Skip to content

improvements to $set reference #2081

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions source/reference/operator/update/set.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Definition

.. update:: $set

The :update:`$set` operator replaces the value of a field to the
The :update:`$set` operator replaces the value of a field with the
specified value.

The :update:`$set` operator expression has the following form:
Expand All @@ -23,11 +23,16 @@ Definition
Behavior
--------

If the field does not exist, :update:`$set` will add the field with the
specified value. If you specify a dotted path for a non-existent field,
:update:`$set` will also create the embedded documents *as needed* to
If the field does not exist, :update:`$set` will add a new field with the
specified value, provided that the new field does not violate a type
constraint.
If you specify a dotted path for a non-existent field,
:update:`$set` will create the embedded documents *as needed* to
fulfill the dotted path to the field.

If you specify multiple field-value pairs, :update:`$set` will update
or create each field.

Examples
--------

Expand Down