AI 에이전트의 경우: 문서 인덱스는 https://www.mongodb.com/ko-kr/docs/llms.txt에서 사용할 수 있으며, 모든 페이지의 마크다운 버전은 어떤 URL 경로에 .md를 추가하여 사용할 수 있습니다.
Docs Menu

$pullAll (업데이트 연산자)

$pullAll

The $pullAll operator removes all instances of the specified values from an existing array. Unlike the $pull operator that removes elements by specifying a query, $pullAll removes elements that match the listed values.

The $pullAll operator has the form:

{ $pullAll: { <field1>: [ <value1>, <value2> ... ], ... } }

내장된 문서나 배열에 <field> 기호를 지정하려면 점 표기법을사용하십시오.

MongoDB 5.0부터 업데이트 연산자는 문자열 기반 이름이 있는 문서 필드를 사전순으로 처리합니다. 숫자 이름이 있는 필드는 숫자 순서대로 처리됩니다. 자세한 내용은 업데이트 운영자 동작을 참조하십시오.

If a <value> to remove is a document or an array, $pullAll removes only the elements in the array that match the specified <value> exactly, including order.

Starting in MongoDB 5.0, mongod no longer raises an error when you use an update operator like $pullAll with an empty operand expression ( { } ). An empty update results in no changes and no oplog entry is created (meaning that the operation is a no-op).

survey 컬렉션을 생성합니다.

db.survey.insertOne( { _id: 1, scores: [ 0, 2, 5, 5, 1, 0 ] } )

다음 작업은 scores 배열에서 "0" 및 "5" 값의 모든 인스턴스를 제거합니다.

db.survey.updateOne( { _id: 1 }, { $pullAll: { scores: [ 0, 5 ] } } )

업데이트 후에는 scores 필드에 더 이상 "0" 또는 "5" 인스턴스가 없습니다.

{ "_id" : 1, "scores" : [ 2, 1 ] }
이 페이지 평가하기

이 페이지의 내용