MongoDB\ClientBulkWrite::insertOne()
버전 2.1에 추가 되었습니다.
정의
MongoDB\ClientBulkWrite::insertOne()
Specify an insert operation in the bulk write command. This method returns the
MongoDB\ClientBulkWrite
instance on which it's called.function insertOne( array|object $document, mixed &$id = null ): self
매개변수
$document
: 배열|객체- 컬렉션에 삽입할 문서입니다.
$id
: 혼합- Captures the document's
_id
field value to store in an optional output variable.
오류/예외
MongoDB\Exception\InvalidArgumentException
매개변수 또는 옵션의 구문 분석과 관련된 오류의 경우입니다.
쓰기 (write) 작업과 관련된 오류의 경우 MongoDB\ 드라이버 \Exception\BulkWriteCommandException. getWriteErrors()가 반환한 값을 검사하여 오류의 특성을 확인할 수 있습니다.
MongoDB\ 드라이버\Exception\RuntimeException 확장 수준의 다른 오류(예: 연결 오류).
행동
MongoDB\ 드라이버\Exception\BulkWriteCommandException이 발생하면 getWriteErrors()를 호출하고 반환된 배열 의 정보를 검사하여 오류의 특성을 확인할 수 있습니다.
예시 를 들어, 쓰기 (write) 작업이 프라이머리 서버 에 성공적으로 적용되었지만 쓰기 고려 (write concern) 충족하지 못했을 수 있습니다. 또는 쓰기 (write) 작업이 완전히 실패했을 수도 있습니다( 예시 : 고유 키 제약 조건 위반).
다음도 참조하세요.
대량 쓰기 작업 가이드 의 클라이언트 대량 쓰기 섹션