모듈: Mongo::Collection::View::Writable

포함 항목:
Mongo::Collection::View
다음에 정의됨:
lib/ Mongo/ 컬렉션/view/writable.rb

개요

컬렉션 보기에 대한 쓰기 (write) 관련 동작을 정의합니다.

이후:

  • 2.0.0

상수 요약 접기

ARRAY_FILTERS =

배열은 필드 상수를 필터링합니다.

이후:

  • 2.5.0

'array_filters'.동결

인스턴스 메서드 요약 접기

인스턴스 메서드 세부 정보

#delete_many(opts = {}) ⇒ 결과

컬렉션 에서 문서를 제거합니다.

예시:

컬렉션에서 여러 문서를 제거합니다.

collection_view.delete_many

매개변수:

  • opts (해시) (기본값: {})

    옵션.

  • 옵션 (해시)

    사용자 지정 가능한 옵션 세트

옵션 해시(opts):

  • :collation (해시)

    사용할 데이터 정렬입니다.

  • :session (세션)

    사용할 세션입니다.

  • :hint (해시 | string)

    이 작업에 사용할 인덱스입니다. 해시(예: { _id: 1 }) 또는 string (예: 'ID ').

  • :write_concern (해시)

    쓰기 고려 (write concern) 옵션. :w => 정수, : fsync => 부울, :j => 부울일 수 있습니다.

  • :let (해시)

    명령에 사용할 변수를 매핑합니다. 자세한 내용은 서버 설명서를 참조하세요.

  • :comment (객체)

    이 명령에 첨부할 사용자 제공 코멘트입니다.

반환합니다:

  • (결과)

    데이터베이스 의 응답입니다.

이후:

  • 2.0.0



257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
# 파일 'lib/ Mongo/ 컬렉션/view/writable.rb', 줄 257

def delete_many(opts = {})
  with_session(opts) do |Session|
    write_concern = 만약 opts[:write_concern]
      writeConcern.get(opts[:write_concern])
    other
      write_concern_with_session(Session)
    end

    쿼리 캐시.clear_namespace(컬렉션.namespace)

    delete_doc = {
      작업::q => 필터,
      작업::LIMIT => 0,
      hint: opts[:hint],
      데이터 정렬: opts[:collation] || opts['데이터 정렬'] || 데이터 정렬,
    }.컴팩트
    컨텍스트 = 작업::Context.신규(
      클라이언트: 고객,
      세션: Session,
      operation_timeout: operation_timeout(opts)
    )
    nro_write_with_retry(write_concern, 컨텍스트: 컨텍스트) do |연결, txn_num, 컨텍스트|
      gte_4_4 = 연결.서버.description.server_version_gte?('4.4')
      만약 !gte_4_4 && opts[:hint] && write_concern && !write_concern.인정?
        올리다 오류::UnsupportedOption.hint_error(unacknowledged_write: true)
      end

      작업::삭제.신규(
        삭제합니다: [ delete_doc ],
        db_name: 컬렉션.database.이름,
        coll_name: 컬렉션.이름,
        write_concern: write_concern,
        bypass_document_validation: !!opts[:bypass_document_validation],
        세션: Session,
        let: opts[:let],
        comment: opts[:comment],
      ).execution_with_connection(연결, 컨텍스트: 컨텍스트)
    end
  end
end

#delete_one(opts = {}) ⇒ 결과

컬렉션 에서 문서 를 제거합니다.

예시:

컬렉션 에서 단일 문서 를 제거합니다.

collection_view.delete_one

매개변수:

  • opts (해시) (기본값: {})

    옵션.

  • 옵션 (해시)

    사용자 지정 가능한 옵션 세트

옵션 해시(opts):

  • :collation (해시)

    사용할 데이터 정렬입니다.

  • :comment (객체)

    이 명령에 첨부할 사용자 제공 코멘트입니다.

  • :hint (해시 | string)

    이 작업에 사용할 인덱스입니다. 해시(예: { _id: 1 }) 또는 string (예: 'ID ').

  • :let (해시)

    명령에 사용할 변수를 매핑합니다. 자세한 내용은 서버 설명서를 참조하세요.

  • :session (세션)

    사용할 세션입니다.

  • :write_concern (해시)

    쓰기 고려 (write concern) 옵션. :w => 정수, : fsync => 부울, :j => 부울일 수 있습니다.

반환합니다:

  • (결과)

    데이터베이스 의 응답입니다.

이후:

  • 2.0.0



323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
# 파일 'lib/ Mongo/ 컬렉션/view/writable.rb', 줄 323

def delete_one(opts = {})
  with_session(opts) do |Session|
    write_concern = 만약 opts[:write_concern]
      writeConcern.get(opts[:write_concern])
    other
      write_concern_with_session(Session)
    end

    쿼리 캐시.clear_namespace(컬렉션.namespace)

    delete_doc = {
      작업::q => 필터,
      작업::LIMIT => 1,
      hint: opts[:hint],
      데이터 정렬: opts[:collation] || opts['데이터 정렬'] || 데이터 정렬,
    }.컴팩트

    컨텍스트 = 작업::Context.신규(
      클라이언트: 고객,
      세션: Session,
      operation_timeout: operation_timeout(opts)
    )
    write_with_retry(write_concern, 컨텍스트: 컨텍스트) do |연결, txn_num, 컨텍스트|
      gte_4_4 = 연결.서버.description.server_version_gte?('4.4')
      만약 !gte_4_4 && opts[:hint] && write_concern && !write_concern.인정?
        올리다 오류::UnsupportedOption.hint_error(unacknowledged_write: true)
      end

      작업::삭제.신규(
        삭제합니다: [ delete_doc ],
        db_name: 컬렉션.database.이름,
        coll_name: 컬렉션.이름,
        write_concern: write_concern,
        bypass_document_validation: !!opts[:bypass_document_validation],
        세션: Session,
        txn_num: txn_num,
        let: opts[:let],
        comment: opts[:comment],
      ).execution_with_connection(연결, 컨텍스트: 컨텍스트)
    end
  end
end

#find_one_and_delete(opts = {}) ⇒ BSON::Document?

findAndModify를 통해 데이터베이스에서 단일 문서를 찾아 삭제하고 원본 문서를 반환합니다.

예시:

하나의 문서 를 찾아 삭제 합니다.

view.find_one_and_delete

매개변수:

  • opts (해시) (기본값: {})

    옵션.

  • 옵션 (해시)

    사용자 지정 가능한 옵션 세트

옵션 해시(opts):

  • :max_time_ms (정수)

    명령이 실행 수 있는 최대 시간(밀리초)입니다. 이 옵션은 더 이상 사용되지 않으므로 대신 :timeout_ms를 사용하세요.

  • :projection (해시)

    반환된 문서에 포함하거나 제외할 필드입니다.

  • :sort (해시)

    결과 설정하다 의 정렬 기준이 되는 키 및 방향 쌍입니다.

  • :collation (해시)

    사용할 데이터 정렬입니다.

  • :session (세션)

    사용할 세션입니다.

  • :hint (해시 | string)

    이 작업에 사용할 인덱스입니다. 해시(예: { _id: 1 }) 또는 string (예: 'ID ').

  • :write_concern (해시)

    쓰기 고려 (write concern) 옵션. :w => 정수, : fsync => 부울, :j => 부울일 수 있습니다.

  • :let (해시)

    명령에 사용할 변수를 매핑합니다. 자세한 내용은 서버 설명서를 참조하세요.

  • :comment (객체)

    이 명령에 첨부할 사용자 제공 코멘트입니다.

반환합니다:

  • (BSON::Document, nil)

    문서(있는 경우).

이후:

  • 2.0.0



64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
# 파일 'lib/ Mongo/ 컬렉션/view/writable.rb', 줄 64

def find_one_and_delete(opts = {})
  with_session(opts) do |Session|
    write_concern = 만약 opts[:write_concern]
      writeConcern.get(opts[:write_concern])
    other
      write_concern_with_session(Session)
    end

    쿼리 캐시.clear_namespace(컬렉션.namespace)

    cmd = {
      findAndModify: 컬렉션.이름,
      query: 필터,
      제거: true,
      필드: 프로젝션,
      sort: sort,
      maxTimeMS: max_time_ms,
      bypassDocumentValidation: opts[:bypass_document_validation],
      hint: opts[:hint],
      데이터 정렬: opts[:collation] || opts['데이터 정렬'] || 데이터 정렬,
      let: opts[:let],
      comment: opts[:comment],
    }.컴팩트

    컨텍스트 = 작업::Context.신규(
      클라이언트: 고객,
      세션: Session,
      operation_timeout: operation_timeout(opts)
    )
    write_with_retry(write_concern, 컨텍스트: 컨텍스트) do |연결, txn_num, 컨텍스트|
      gte_4_4 = 연결.서버.description.server_version_gte?('4.4')
      만약 !gte_4_4 && opts[:hint] && write_concern && !write_concern.인정?
        올리다 오류::UnsupportedOption.hint_error(unacknowledged_write: true)
      end

      작업::WriteCommand.신규(
        선택기: cmd,
        db_name: database.이름,
        write_concern: write_concern,
        세션: Session,
        txn_num: txn_num,
      ).execution_with_connection(연결, 컨텍스트: 컨텍스트)
    end
  end.first&.가져오기('value', nil)
end

#find_one_and_replace(replacement, opts = {}) ⇒ BSON::Document

하나의 문서를 찾아서 대체합니다.

예시:

문서 를 찾아 교체하고 원본을 반환합니다.

view.find_one_and_replace({ name: 'test' }, :return_document => :before)

문서 를 찾아 교체하고 새 문서 를 반환합니다.

view.find_one_and_replace({ name: 'test' }, :return_document => :after)

매개변수:

  • 교체 (BSON::Document)

    교체.

  • opts (해시) (기본값: {})

    옵션.

  • 옵션 (해시)

    사용자 지정 가능한 옵션 세트

옵션 해시(opts):

  • :return_document (기호)

    :before 또는 :after.

  • : 업서트 (true, false)

    문서 가 존재하지 않는 경우 업서트 할지 여부입니다.

  • :bypass_document_validation (true, false)

    문서 수준 유효성 검사 를 건너뛸지 여부입니다.

  • :collation (해시)

    사용할 데이터 정렬입니다.

  • :hint (해시 | string)

    이 작업에 사용할 인덱스입니다. 해시(예: { _id: 1 }) 또는 string (예: 'ID ').

  • :write_concern (해시)

    쓰기 고려 (write concern) 옵션. :w => 정수, : fsync => 부울, :j => 부울일 수 있습니다.

  • :let (해시)

    명령에 사용할 변수를 매핑합니다. 자세한 내용은 서버 설명서를 참조하세요.

반환합니다:

  • (BSON::Document)

    문서입니다.

이후:

  • 2.0.0



140
141
142
# 파일 'lib/ Mongo/ 컬렉션/view/writable.rb', 줄 140

def find_one_and_replace(교체, opts = {})
  find_one_and_update(교체, opts)
end

#find_one_and_update(document, opts = {}) ⇒ BSON::Document | nil

단일 문서를 찾아서 업데이트합니다.

업데이트 가 적용 되어야 합니다.

예시:

문서 를 찾아 업데이트 하고 원본을 반환합니다.

view.find_one_and_update({ "$set" => { name: 'test' }}, :return_document => :before)

매개변수:

  • 문서 (BSON::Document)

    업데이트.

  • opts (해시) (기본값: {})

    옵션.

  • 옵션 (해시)

    사용자 지정 가능한 옵션 세트

옵션 해시(opts):

  • :max_time_ms (정수)

    명령이 실행 수 있는 최대 시간(밀리초)입니다. 이 옵션은 더 이상 사용되지 않으므로 대신 :timeout_ms를 사용하세요.

  • :projection (해시)

    반환된 문서에 포함하거나 제외할 필드입니다.

  • :sort (해시)

    결과 설정하다 의 정렬 기준이 되는 키 및 방향 쌍입니다.

  • :return_document (기호)

    :before 또는 :after.

  • : 업서트 (true, false)

    문서 가 존재하지 않는 경우 업서트 할지 여부입니다.

  • :bypass_document_validation (true, false)

    문서 수준 유효성 검사 를 건너뛸지 여부입니다.

  • :collation (해시)

    사용할 데이터 정렬입니다.

  • :array_filters (배열)

    배열 요소를 지정하는 필터 설정하다 입니다.

  • :session (세션)

    사용할 세션입니다.

  • :hint (해시 | string)

    이 작업에 사용할 인덱스입니다. 해시(예: { _id: 1 }) 또는 string (예: 'ID ').

  • :write_concern (해시)

    쓰기 고려 (write concern) 옵션. :w => 정수, : fsync => 부울, :j => 부울일 수 있습니다.

  • :let (해시)

    명령에 사용할 변수를 매핑합니다. 자세한 내용은 서버 설명서를 참조하세요.

  • :comment (객체)

    이 명령에 첨부할 사용자 제공 코멘트입니다.

반환합니다:

  • (BSON::Document | nil)

    문서를 반환하거나, 문서를 찾을 수 없는 경우 nil을 반환합니다.

이후:

  • 2.0.0



182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
# 파일 'lib/ Mongo/ 컬렉션/view/writable.rb', 줄 182

def find_one_and_update(문서, opts = {})
  value = with_session(opts) do |Session|
    write_concern = 만약 opts[:write_concern]
      writeConcern.get(opts[:write_concern])
    other
      write_concern_with_session(Session)
    end

    쿼리 캐시.clear_namespace(컬렉션.namespace)

    cmd = {
      findAndModify: 컬렉션.이름,
      query: 필터,
      arrayFilters: opts[:array_filters] || opts['array_filters'],
      update: 문서,
      필드: 프로젝션,
      sort: sort,
      new: !!(opts[:return_document] && opts[:return_document] == :after),
      upsert: opts[: 업서트],
      maxTimeMS: max_time_ms,
      bypassDocumentValidation: opts[:bypass_document_validation],
      hint: opts[:hint],
      데이터 정렬: opts[:collation] || opts['데이터 정렬'] || 데이터 정렬,
      let: opts[:let],
      comment: opts[:comment]
    }.컴팩트

    컨텍스트 = 작업::Context.신규(
      클라이언트: 고객,
      세션: Session,
      operation_timeout: operation_timeout(opts)
    )
    write_with_retry(write_concern, 컨텍스트: 컨텍스트) do |연결, txn_num, 컨텍스트|
      gte_4_4 = 연결.서버.description.server_version_gte?('4.4')
      만약 !gte_4_4 && opts[:hint] && write_concern && !write_concern.인정?
        올리다 오류::UnsupportedOption.hint_error(unacknowledged_write: true)
      end

      작업::WriteCommand.신규(
        선택기: cmd,
        db_name: database.이름,
        write_concern: write_concern,
        세션: Session,
        txn_num: txn_num,
      ).execution_with_connection(연결, 컨텍스트: 컨텍스트)
    end
  end.first&.가져오기('value', nil)
  value 하지 않는 한 value.nil? || value.비어 있나요?
end

#replace_one(replacement, opts = {}) ⇒ 결과

데이터베이스 의 단일 문서 를 새 문서 로 바꿉니다.

예시:

단일 문서 를 교체합니다.

collection_view.replace_one({ name: 'test' })

매개변수:

  • 교체 (해시)

    대체 문서입니다.

  • opts (해시) (기본값: {})

    옵션.

  • 옵션 (해시)

    사용자 지정 가능한 옵션 세트

옵션 해시(opts):

  • :bypass_document_validation (true, false)

    문서 수준 유효성 검사 를 건너뛸지 여부입니다.

  • :collation (해시)

    사용할 데이터 정렬입니다.

  • :comment (객체)

    이 명령에 첨부할 사용자 제공 코멘트입니다.

  • :hint (해시 | string)

    이 작업에 사용할 인덱스입니다. 해시(예: { _id: 1 }) 또는 string (예: 'ID ').

  • :let (해시)

    명령에 사용할 변수를 매핑합니다. 자세한 내용은 서버 설명서를 참조하세요.

  • :session (세션)

    사용할 세션입니다.

  • :write_concern (해시)

    쓰기 고려 (write concern) 옵션.

  • : 업서트 (true, false)

    문서 존재하지 않는 경우 업서트 할지 여부입니다. :w => 정수, : fsync => 부울, :j => 부울일 수 있습니다.

반환합니다:

  • (결과)

    데이터베이스 의 응답입니다.

이후:

  • 2.0.0



396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
# 파일 'lib/ Mongo/ 컬렉션/view/writable.rb', 줄 396

def replace_one(교체, opts = {})
  with_session(opts) do |Session|
    write_concern = 만약 opts[:write_concern]
      writeConcern.get(opts[:write_concern])
    other
      write_concern_with_session(Session)
    end
    validate_replacement_documents!(교체)

    쿼리 캐시.clear_namespace(컬렉션.namespace)

    update_doc = {
      작업::q => 필터,
      arrayFilters: opts[:array_filters] || opts['array_filters'],
      작업::u => 교체,
      hint: opts[:hint],
      데이터 정렬: opts[:collation] || opts['데이터 정렬'] || 데이터 정렬,
    }.컴팩트
    만약 opts[: 업서트]
      update_doc['upsert'] = true
    end

    컨텍스트 = 작업::Context.신규(
      클라이언트: 고객,
      세션: Session,
      operation_timeout: operation_timeout(opts)
    )
    write_with_retry(write_concern, 컨텍스트: 컨텍스트) do |연결, txn_num, 컨텍스트|
      gte_4_2 = 연결.서버.description.server_version_gte?('4.2')
      만약 !gte_4_2 && opts[:hint] && write_concern && !write_concern.인정?
        올리다 오류::UnsupportedOption.hint_error(unacknowledged_write: true)
      end

      작업::Update.신규(
        updates: [ update_doc ],
        db_name: 컬렉션.database.이름,
        coll_name: 컬렉션.이름,
        write_concern: write_concern,
        bypass_document_validation: !!opts[:bypass_document_validation],
        세션: Session,
        txn_num: txn_num,
        let: opts[:let],
        comment: opts[:comment],
      ).execution_with_connection(연결, 컨텍스트: 컨텍스트)
    end
  end
end

#update_many(spec, opts = {}) ⇒ 결과

컬렉션 의 문서를 업데이트합니다.

예시:

컬렉션 에서 여러 문서를 업데이트합니다.

collection_view.update_many('$set' => { name: 'test' })

매개변수:

  • 사양 (해시 | Array<Hash>)

    업데이트 문서 또는 파이프라인.

  • opts (해시) (기본값: {})

    옵션.

  • 옵션 (해시)

    사용자 지정 가능한 옵션 세트

옵션 해시(opts):

  • :array_filters (배열)

    업데이트 를 적용 해야 하는 배열 요소를 지정하는 필터 설정하다 입니다.

  • :bypass_document_validation (true, false)

    문서 수준 유효성 검사 를 건너뛸지 여부입니다.

  • :collation (해시)

    사용할 데이터 정렬입니다.

  • :comment (객체)

    이 명령에 첨부할 사용자 제공 코멘트입니다.

  • :hint (해시 | string)

    이 작업에 사용할 인덱스입니다. 해시(예: { _id: 1 }) 또는 string (예: 'ID ').

  • :let (해시)

    명령에 사용할 변수를 매핑합니다. 자세한 내용은 서버 설명서를 참조하세요.

  • :session (세션)

    사용할 세션입니다.

  • : 업서트 (true, false)

    문서 가 존재하지 않는 경우 업서트 할지 여부입니다.

  • :write_concern (해시)

    쓰기 고려 (write concern) 옵션. :w => 정수, : fsync => 부울, :j => 부울일 수 있습니다.

반환합니다:

  • (결과)

    데이터베이스 의 응답입니다.

이후:

  • 2.0.0



476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
# 파일 'lib/ Mongo/ 컬렉션/view/writable.rb', 줄 476

def update_many(사양, opts = {})
  with_session(opts) do |Session|
    write_concern = 만약 opts[:write_concern]
      writeConcern.get(opts[:write_concern])
    other
      write_concern_with_session(Session)
    end
    validate_update_documents!(사양)

    쿼리 캐시.clear_namespace(컬렉션.namespace)

    update_doc = {
      작업::q => 필터,
      arrayFilters: opts[:array_filters] || opts['array_filters'],
      작업::u => 사양,
      작업::멀티 => true,
      hint: opts[:hint],
      데이터 정렬: opts[:collation] || opts['데이터 정렬'] || 데이터 정렬,
    }.컴팩트
    만약 opts[: 업서트]
      update_doc['upsert'] = true
    end

    컨텍스트 = 작업::Context.신규(
      클라이언트: 고객,
      세션: Session,
      operation_timeout: operation_timeout(opts)
    )
    nro_write_with_retry(write_concern, 컨텍스트: 컨텍스트) do |연결, txn_num, 컨텍스트|
      gte_4_2 = 연결.서버.description.server_version_gte?('4.2')
      만약 !gte_4_2 && opts[:hint] && write_concern && !write_concern.인정?
        올리다 오류::UnsupportedOption.hint_error(unacknowledged_write: true)
      end

      작업::Update.신규(
        updates: [ update_doc ],
        db_name: 컬렉션.database.이름,
        coll_name: 컬렉션.이름,
        write_concern: write_concern,
        bypass_document_validation: !!opts[:bypass_document_validation],
        세션: Session,
        let: opts[:let],
        comment: opts[:comment],
      ).execution_with_connection(연결, 컨텍스트: 컨텍스트)
    end
  end
end

#update_one(spec, opts = {}) ⇒ 결과

컬렉션 에서 단일 문서 를 업데이트합니다.

예시:

컬렉션 에서 단일 문서 를 업데이트합니다.

collection_view.update_one('$set' => { name: 'test' })

매개변수:

  • 사양 (해시 | Array<Hash>)

    업데이트 문서 또는 파이프라인.

  • opts (해시) (기본값: {})

    옵션.

  • 옵션 (해시)

    사용자 지정 가능한 옵션 세트

옵션 해시(opts):

  • :array_filters (배열)

    업데이트 를 적용 해야 하는 배열 요소를 지정하는 필터 설정하다 입니다.

  • :bypass_document_validation (true, false)

    문서 수준 유효성 검사 를 건너뛸지 여부입니다.

  • :collation (해시)

    사용할 데이터 정렬입니다.

  • :comment (객체)

    이 명령에 첨부할 사용자 제공 코멘트입니다.

  • :hint (해시 | string)

    이 작업에 사용할 인덱스입니다. 해시(예: { _id: 1 }) 또는 string (예: 'ID ').

  • :let (해시)

    명령에 사용할 변수를 매핑합니다. 자세한 내용은 서버 설명서를 참조하세요.

  • :session (세션)

    사용할 세션입니다.

  • : 업서트 (true, false)

    문서 가 존재하지 않는 경우 업서트 할지 여부입니다.

  • :write_concern (해시)

    쓰기 고려 (write concern) 옵션. :w => 정수, : fsync => 부울, :j => 부울일 수 있습니다.

반환합니다:

  • (결과)

    데이터베이스 의 응답입니다.

이후:

  • 2.0.0



556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
# 파일 'lib/ Mongo/ 컬렉션/view/writable.rb', 줄 556

def update_one(사양, opts = {})
  with_session(opts) do |Session|
    write_concern = 만약 opts[:write_concern]
      writeConcern.get(opts[:write_concern])
    other
      write_concern_with_session(Session)
    end
    validate_update_documents!(사양)

    쿼리 캐시.clear_namespace(컬렉션.namespace)

    update_doc = {
      작업::q => 필터,
      arrayFilters: opts[:array_filters] || opts['array_filters'],
      작업::u => 사양,
      hint: opts[:hint],
      데이터 정렬: opts[:collation] || opts['데이터 정렬'] || 데이터 정렬,
    }.컴팩트
    만약 opts[: 업서트]
      update_doc['upsert'] = true
    end

    컨텍스트 = 작업::Context.신규(
      클라이언트: 고객,
      세션: Session,
      operation_timeout: operation_timeout(opts)
    )
    write_with_retry(write_concern, 컨텍스트: 컨텍스트) do |연결, txn_num, 컨텍스트|
      gte_4_2 = 연결.서버.description.server_version_gte?('4.2')
      만약 !gte_4_2 && opts[:hint] && write_concern && !write_concern.인정?
        올리다 오류::UnsupportedOption.hint_error(unacknowledged_write: true)
      end

      작업::Update.신규(
        updates: [ update_doc ],
        db_name: 컬렉션.database.이름,
        coll_name: 컬렉션.이름,
        write_concern: write_concern,
        bypass_document_validation: !!opts[:bypass_document_validation],
        세션: Session,
        txn_num: txn_num,
        let: opts[:let],
        comment: opts[:comment],
      ).execution_with_connection(연결, 컨텍스트: 컨텍스트)
    end
  end
end