モジュール: Mongo::Collection::View::Writable
- 次のドキュメントに含まれます。
- Mongo::Collection::View
- 定義:
- lib/mongo/ コレクション/view/writeable.rb
Overview
コレクション ビューの書込み関連の動作を定義します。
定数の概要の削減
- Array_Filters =
配列フィルター フィールド定数。
' array_filters '.freeze
インスタンス メソッドの概要を折りたたむ
-
delete_many (opts = {}) = 結果 = 結果
コレクションからドキュメントを削除します。
-
# delete_one (ops = {}) = 結果
コレクションからドキュメントを削除します。
-
#find_one_and_delete(opts = {}) ⇒ BSON::Document?
findAndModify 経由でデータベース内の単一のドキュメントを検索し、削除し、元のドキュメントを返します。
-
# find_one_and_replace (置換、opts = {{}) = BSON::Document
1 つのドキュメントを検索して置き換えます。
-
#find_one_and_update(document, opts = {}) ⇒ BSON::Document | nil
1 つのドキュメントを検索してアップデートします。
-
# replace_one (置換, opts = {}) = 結果
データベース内の単一のドキュメントを新しいドキュメントに置き換えます。
-
# update_many (spec, opts = {}) = 結果
コレクション内のドキュメントを更新します。
-
#update_one(spec, opts = {}) ⇒ Result
コレクション内の 1 つのドキュメントを更新します。
インスタンス メソッドの詳細
delete_many (opts = {}) = 結果 =結果
コレクションからドキュメントを削除します。
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/writeable.rb' は、257 行 デフォルト delete_many(ops = {}) with_session(ops) 行う |セッション| write_concern = 場合 ops[:write_concern] WriteConcern.得る(ops[:write_concern]) else write_concern_with_session(セッション) end クエリ キャッシュ.clear_namespace(コレクション.namespace) delete_doc = { 操作::q => フィルター, 操作::LIMIT => 0, hint: ops[:hint], collation: ops[:collation] || ops[「照合」] || collation, }.compact context = 操作::Context.新着情報( クライアント: クライアント, セッション: セッション, operation_timeouts: operation_timeouts(ops) ) nro_write_with_retry(write_concern, context: context) 行う |接続, txn_num, context| gte_4_4 = 接続.サーバー.説明.server_version_gte?('4.4') 場合 !gte_4_4 & & ops[:hint] & & write_concern & & !write_concern.確認済み? 発生 エラー::UnsupportedOption.hint_error(unacknowledged_write: true) end 操作::削除.新着情報( 次の値を削除します。 [ delete_doc ], db_name: コレクション.database.name, coll_name: コレクション.name, write_concern: write_concern, bypass_document_validation: !!ops[:bypass_document_validation], セッション: セッション, let: ops[:let], comment: ops[:comment], ).execution_with_ connection(接続, context: context) end end end |
# delete_one (ops = {}) =結果
コレクションからドキュメントを削除します。
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/writeable.rb' は、323 行 デフォルト delete_one(ops = {}) with_session(ops) 行う |セッション| write_concern = 場合 ops[:write_concern] WriteConcern.得る(ops[:write_concern]) else write_concern_with_session(セッション) end クエリ キャッシュ.clear_namespace(コレクション.namespace) delete_doc = { 操作::q => フィルター, 操作::LIMIT => 1, hint: ops[:hint], collation: ops[:collation] || ops[「照合」] || collation, }.compact context = 操作::Context.新着情報( クライアント: クライアント, セッション: セッション, operation_timeouts: operation_timeouts(ops) ) write_with_retry(write_concern, context: context) 行う |接続, txn_num, context| gte_4_4 = 接続.サーバー.説明.server_version_gte?('4.4') 場合 !gte_4_4 & & ops[:hint] & & write_concern & & !write_concern.確認済み? 発生 エラー::UnsupportedOption.hint_error(unacknowledged_write: true) end 操作::削除.新着情報( 次の値を削除します。 [ delete_doc ], db_name: コレクション.database.name, coll_name: コレクション.name, write_concern: write_concern, bypass_document_validation: !!ops[:bypass_document_validation], セッション: セッション, txn_num: txn_num, let: ops[:let], comment: ops[:comment], ).execution_with_ connection(接続, context: context) end end end |
#find_one_and_delete(opts = {}) ⇒ BSON::Document?
findAndModify 経由でデータベース内の単一のドキュメントを検索し、削除し、元のドキュメントを返します。
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/writeable.rb' は、64 行 デフォルト find_one_and_delete(ops = {}) with_session(ops) 行う |セッション| write_concern = 場合 ops[:write_concern] WriteConcern.得る(ops[:write_concern]) else write_concern_with_session(セッション) end クエリ キャッシュ.clear_namespace(コレクション.namespace) cmd = { findAndModify: コレクション.name, query: フィルター, 以下を削除します。 true, フィールド: プロジェクション, sort: sort, maxTimeMS: max_time_ms, bypassDocumentValidation: ops[:bypass_document_validation], hint: ops[:hint], collation: ops[:collation] || ops[「照合」] || collation, let: ops[:let], comment: ops[:comment], }.compact context = 操作::Context.新着情報( クライアント: クライアント, セッション: セッション, operation_timeouts: operation_timeouts(ops) ) write_with_retry(write_concern, context: context) 行う |接続, txn_num, context| gte_4_4 = 接続.サーバー.説明.server_version_gte?('4.4') 場合 !gte_4_4 & & ops[:hint] & & write_concern & & !write_concern.確認済み? 発生 エラー::UnsupportedOption.hint_error(unacknowledged_write: true) end 操作::WriteCommand.新着情報( セレクター: cmd, db_name: database.name, write_concern: write_concern, セッション: セッション, txn_num: txn_num, ).execution_with_ connection(接続, context: context) end end.最初に&.fetch('value', nil) end |
# find_one_and_replace (置換、opts = {{}) = BSON::Document
1 つのドキュメントを検索して置き換えます。
140 141 142 |
# ファイル 'lib/mongo/ コレクション/view/writeable.rb' は、140 行 デフォルト find_one_and_replace(replacement, ops = {}) find_one_and_update(replacement, ops) end |
#find_one_and_update(document, opts = {}) ⇒ BSON::Document | nil
1 つのドキュメントを検索してアップデートします。
更新を適用する必要があります。
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/writeable.rb' は、182 行 デフォルト find_one_and_update(ドキュメント, ops = {}) 価値 = with_session(ops) 行う |セッション| write_concern = 場合 ops[:write_concern] WriteConcern.得る(ops[:write_concern]) else write_concern_with_session(セッション) end クエリ キャッシュ.clear_namespace(コレクション.namespace) cmd = { findAndModify: コレクション.name, query: フィルター, arrayFilters: ops[:array_filters] || ops[' array_filters '], update: ドキュメント, フィールド: プロジェクション, sort: sort, new: !!(ops[:return_document] & & ops[:return_document] == : after), アップサート: ops[:upsert], maxTimeMS: max_time_ms, bypassDocumentValidation: ops[:bypass_document_validation], hint: ops[:hint], collation: ops[:collation] || ops[「照合」] || collation, let: ops[:let], comment: ops[:comment] }.compact context = 操作::Context.新着情報( クライアント: クライアント, セッション: セッション, operation_timeouts: operation_timeouts(ops) ) write_with_retry(write_concern, context: context) 行う |接続, txn_num, context| gte_4_4 = 接続.サーバー.説明.server_version_gte?('4.4') 場合 !gte_4_4 & & ops[:hint] & & write_concern & & !write_concern.確認済み? 発生 エラー::UnsupportedOption.hint_error(unacknowledged_write: true) end 操作::WriteCommand.新着情報( セレクター: cmd, db_name: database.name, write_concern: write_concern, セッション: セッション, txn_num: txn_num, ).execution_with_ connection(接続, context: context) end end.最初に&.fetch('value', nil) 価値 ただし、 価値.nil? || 価値.空の場合 end |
# replace_one (置換, opts = {}) =結果
データベース内の単一のドキュメントを新しいドキュメントに置き換えます。
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/writeable.rb' は、396 行 デフォルト replace_one(replacement, ops = {}) with_session(ops) 行う |セッション| write_concern = 場合 ops[:write_concern] WriteConcern.得る(ops[:write_concern]) else write_concern_with_session(セッション) end validate_replacement_documents(replacement) クエリ キャッシュ.clear_namespace(コレクション.namespace) update_doc = { 操作::q => フィルター, arrayFilters: ops[:array_filters] || ops[' array_filters '], 操作::U => replacement, hint: ops[:hint], collation: ops[:collation] || ops[「照合」] || collation, }.compact 場合 ops[:upsert] update_doc['upsert'] = true end context = 操作::Context.新着情報( クライアント: クライアント, セッション: セッション, operation_timeouts: operation_timeouts(ops) ) write_with_retry(write_concern, context: context) 行う |接続, txn_num, context| gte_4_2 = 接続.サーバー.説明.server_version_gte?('4.2') 場合 !gte_4_2 & & ops[:hint] & & write_concern & & !write_concern.確認済み? 発生 エラー::UnsupportedOption.hint_error(unacknowledged_write: true) end 操作::Update.新着情報( updates: [ update_doc ], db_name: コレクション.database.name, coll_name: コレクション.name, write_concern: write_concern, bypass_document_validation: !!ops[:bypass_document_validation], セッション: セッション, txn_num: txn_num, let: ops[:let], comment: ops[:comment], ).execution_with_ connection(接続, context: context) end end end |
# update_many (spec, opts = {}) =結果
コレクション内のドキュメントを更新します。
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/writeable.rb' は、476 行 デフォルト update_many(スペック, ops = {}) with_session(ops) 行う |セッション| write_concern = 場合 ops[:write_concern] WriteConcern.得る(ops[:write_concern]) else write_concern_with_session(セッション) end validate_update_documents!(スペック) クエリ キャッシュ.clear_namespace(コレクション.namespace) update_doc = { 操作::q => フィルター, arrayFilters: ops[:array_filters] || ops[' array_filters '], 操作::U => スペック, 操作::multi => true, hint: ops[:hint], collation: ops[:collation] || ops[「照合」] || collation, }.compact 場合 ops[:upsert] update_doc['upsert'] = true end context = 操作::Context.新着情報( クライアント: クライアント, セッション: セッション, operation_timeouts: operation_timeouts(ops) ) nro_write_with_retry(write_concern, context: context) 行う |接続, txn_num, context| gte_4_2 = 接続.サーバー.説明.server_version_gte?('4.2') 場合 !gte_4_2 & & ops[:hint] & & write_concern & & !write_concern.確認済み? 発生 エラー::UnsupportedOption.hint_error(unacknowledged_write: true) end 操作::Update.新着情報( updates: [ update_doc ], db_name: コレクション.database.name, coll_name: コレクション.name, write_concern: write_concern, bypass_document_validation: !!ops[:bypass_document_validation], セッション: セッション, let: ops[:let], comment: ops[:comment], ).execution_with_ connection(接続, context: context) end end end |
#update_one(spec, opts = {}) ⇒ Result
コレクション内の 1 つのドキュメントを更新します。
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/writeable.rb' は、556 行 デフォルト update_one(スペック, ops = {}) with_session(ops) 行う |セッション| write_concern = 場合 ops[:write_concern] WriteConcern.得る(ops[:write_concern]) else write_concern_with_session(セッション) end validate_update_documents!(スペック) クエリ キャッシュ.clear_namespace(コレクション.namespace) update_doc = { 操作::q => フィルター, arrayFilters: ops[:array_filters] || ops[' array_filters '], 操作::U => スペック, hint: ops[:hint], collation: ops[:collation] || ops[「照合」] || collation, }.compact 場合 ops[:upsert] update_doc['upsert'] = true end context = 操作::Context.新着情報( クライアント: クライアント, セッション: セッション, operation_timeouts: operation_timeouts(ops) ) write_with_retry(write_concern, context: context) 行う |接続, txn_num, context| gte_4_2 = 接続.サーバー.説明.server_version_gte?('4.2') 場合 !gte_4_2 & & ops[:hint] & & write_concern & & !write_concern.確認済み? 発生 エラー::UnsupportedOption.hint_error(unacknowledged_write: true) end 操作::Update.新着情報( updates: [ update_doc ], db_name: コレクション.database.name, coll_name: コレクション.name, write_concern: write_concern, bypass_document_validation: !!ops[:bypass_document_validation], セッション: セッション, txn_num: txn_num, let: ops[:let], comment: ops[:comment], ).execution_with_ connection(接続, context: context) end end end |