Docs Menu

연산자 업데이트

The following modifiers are available for use in update operations, for example, in db.collection.updateMany() and db.collection.findAndModify().

You can use update operators for deployments hosted in the following environments:

  • MongoDB Atlas: 클라우드에서의 MongoDB 배포를 위한 완전 관리형 서비스

Specify the operator expression in a document of the form:

{
<operator1>: { <field1>: <value1>, ... },
<operator2>: { <field2>: <value2>, ... },
...
}

참고

구문 및 예시를 포함하여 특정 연산자에 대한 자세한 내용을 보려면 연산자의 참조 페이지에 대한 링크를 클릭하십시오.

Starting in MongoDB 5.0, update operators process document fields with string-based names in lexicographic order. Fields with numeric names are processed in numeric order.

Consider this example $set command:

{ $set: { "a.2": <new value>, "a.10": <new value>, } }

In MongoDB 5.0 and later, "a.2" is processed before "a.10" because 2 comes before 10 in numeric order.

이름
설명

Sets the value of a field to current date, either as a Date or a Timestamp.

Increments the value of the field by the specified amount.

Only updates the field if the specified value is less than the existing field value.

Only updates the field if the specified value is greater than the existing field value.

Multiplies the value of the field by the specified amount.

Renames a field.

Sets the value of a field in a document.

Sets the value of a field if an update results in an insert of a document. Has no effect on update operations that modify existing documents.

Removes the specified field from a document.

이름
설명

쿼리 조건과 일치하는 첫 번째 요소를 업데이트하는 자리 표시자 역할을 합니다.

쿼리 조건과 일치하는 문서에 대한 배열의 모든 요소를 업데이트하는 자리 표시자 역할을 합니다.

쿼리 조건과 일치하는 문서의 arrayFilters 조건과 일치하는 모든 요소를 업데이트하는 자리 표시자 역할을 합니다.

집합에 요소가 아직 없는 경우에만 배열에 요소를 추가합니다.

배열의 첫 번째 또는 마지막 항목을 제거합니다.

지정된 쿼리와 일치하는 모든 배열 요소를 제거합니다.

배열에 항목을 추가합니다.

배열에서 일치하는 모든 값을 제거합니다.

이름
설명

배열 업데이트를 위해 여러 항목을 추가하도록 $push$addToSet 연산자를 수정합니다.

요소를 추가할 배열의 위치를 지정하도록 $push 연산자를 수정합니다.

업데이트된 배열의 크기를 제한하도록 $push 연산자를 수정합니다.

배열에 저장된 문서의 순서를 재정렬하도록 $push 연산자를 수정합니다.

이름
설명

Performs bitwise AND, OR, and XOR updates of integer values.