연산자 업데이트
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 배포를 위한 완전 관리형 서비스
MongoDB Enterprise: MongoDB의 구독 기반 자체 관리 버전
MongoDB Community: 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. |
배열
연산자
이름 | 설명 |
---|---|
쿼리 조건과 일치하는 첫 번째 요소를 업데이트하는 자리 표시자 역할을 합니다. | |
쿼리 조건과 일치하는 문서에 대한 배열의 모든 요소를 업데이트하는 자리 표시자 역할을 합니다. | |
쿼리 조건과 일치하는 문서의 | |
집합에 요소가 아직 없는 경우에만 배열에 요소를 추가합니다. | |
배열의 첫 번째 또는 마지막 항목을 제거합니다. | |
지정된 쿼리와 일치하는 모든 배열 요소를 제거합니다. | |
배열에 항목을 추가합니다. | |
배열에서 일치하는 모든 값을 제거합니다. |
Modifiers
비트 단위
이름 | 설명 |
---|---|
Performs bitwise |