Bulk.getOperations()Bulk.execute()를 통해 실행된 쓰기 작업의 배열을 반환합니다. 반환된 쓰기 작업은 MongoDB에서 실행을 위해 결정한 대로 그룹으로 나뉘어져 있습니다. MongoDB가 대량 쓰기 작업 목록을 그룹화하는 방법에 대한 자세한 내용은 Bulk.execute() 동작을 참조하세요.Only use
Bulk.getOperations()after aBulk.execute(). CallingBulk.getOperations()before you callBulk.execute()will result in an incomplete list.
호환성
이 명령은 다음 환경에서 호스팅되는 배포에서 사용할 수 있습니다.
- MongoDB Atlas: 클라우드에서의 MongoDB 배포를 위한 완전 관리형 서비스
참고
이 명령은 모든 MongoDB Atlas 클러스터에서 지원됩니다. 모든 명령에 대한 Atlas 지원에 관해 자세히 알아보려면 지원되지 않는 명령을 참조하세요.
예시
The following initializes a Bulk() operations builder on the items collection, adds a series of write operations, executes the operations, and then calls getOperations() on the bulk builder object:
var bulk = db.items.initializeUnorderedBulkOp(); for (var i = 1; i <= 1500; i++) { bulk.insert( { x: i } ); } bulk.execute(); bulk.getOperations();
getOperations() 메서드는 실행된 작업이 포함된 배열 반환합니다. 출력은 MongoDB 작업을 2 그룹으로 나누었는데, 하나는 작업이 1000 있고 다른 하나는 가 500 있습니다. MongoDB 대량 쓰기 (write) 작업 목록을 그룹화하는 방법에 대한 자세한 내용은 Bulk.execute() 동작을 참조하세요.
이 메서드는 반환된 배열의 1500개의 작업을 모두 반환하지만 이 페이지에서는 간결함을 위해 결과 중 일부를 생략했습니다.
[ { "originalZeroIndex" : 0, "batchType" : 1, "operations" : [ { "_id" : ObjectId("53a8959f1990ca24d01c6165"), "x" : 1 }, ... // Content omitted for brevity { "_id" : ObjectId("53a8959f1990ca24d01c654c"), "x" : 1000 } ] }, { "originalZeroIndex" : 1000, "batchType" : 1, "operations" : [ { "_id" : ObjectId("53a8959f1990ca24d01c654d"), "x" : 1001 }, ... // Content omitted for brevity { "_id" : ObjectId("53a8959f1990ca24d01c6740"), "x" : 1500 } ] } ]
반환된 필드
배열에는 다음 필드가 있는 문서가 포함되어 있습니다.
originalZeroIndexSpecifies the order in which the operation was added to the bulk operations builder, based on a zero index; e.g. first operation added to the bulk operations builder will have
originalZeroIndexvalue of0.