mongo 1.8.6 → 2.15.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- checksums.yaml.gz.sig +0 -0
- data/CONTRIBUTING.md +22 -0
- data/LICENSE +1 -1
- data/README.md +68 -304
- data/Rakefile +280 -11
- data/bin/mongo_console +18 -13
- data/lib/mongo/active_support.rb +20 -0
- data/lib/mongo/address/ipv4.rb +128 -0
- data/lib/mongo/address/ipv6.rb +142 -0
- data/lib/mongo/address/unix.rb +82 -0
- data/lib/mongo/address/validator.rb +102 -0
- data/lib/mongo/address.rb +296 -0
- data/lib/mongo/auth/aws/conversation.rb +128 -0
- data/lib/mongo/auth/aws/credentials_retriever.rb +222 -0
- data/lib/mongo/auth/aws/request.rb +286 -0
- data/lib/mongo/auth/aws.rb +40 -0
- data/lib/mongo/auth/base.rb +138 -0
- data/lib/mongo/auth/conversation_base.rb +87 -0
- data/lib/mongo/auth/cr/conversation.rb +77 -0
- data/lib/mongo/auth/cr.rb +45 -0
- data/lib/mongo/auth/credential_cache.rb +54 -0
- data/lib/mongo/auth/gssapi/conversation.rb +100 -0
- data/lib/mongo/auth/gssapi.rb +41 -0
- data/lib/mongo/auth/ldap/conversation.rb +57 -0
- data/lib/mongo/auth/ldap.rb +42 -0
- data/lib/mongo/auth/roles.rb +107 -0
- data/lib/mongo/auth/sasl_conversation_base.rb +102 -0
- data/lib/mongo/auth/scram/conversation.rb +65 -0
- data/lib/mongo/auth/scram.rb +75 -0
- data/lib/mongo/auth/scram256/conversation.rb +66 -0
- data/lib/mongo/auth/scram256.rb +34 -0
- data/lib/mongo/auth/scram_conversation_base.rb +378 -0
- data/lib/mongo/auth/stringprep/profiles/sasl.rb +77 -0
- data/lib/mongo/auth/stringprep/tables.rb +3236 -0
- data/lib/mongo/auth/stringprep/unicode_normalize/normalize.rb +175 -0
- data/lib/mongo/auth/stringprep/unicode_normalize/tables.rb +1171 -0
- data/lib/mongo/auth/stringprep.rb +118 -0
- data/lib/mongo/auth/user/view.rb +165 -0
- data/lib/mongo/auth/user.rb +225 -0
- data/lib/mongo/auth/x509/conversation.rb +70 -0
- data/lib/mongo/auth/x509.rb +60 -0
- data/lib/mongo/auth.rb +186 -0
- data/lib/mongo/background_thread.rb +173 -0
- data/lib/mongo/bson.rb +35 -0
- data/lib/mongo/bulk_write/combineable.rb +75 -0
- data/lib/mongo/bulk_write/ordered_combiner.rb +58 -0
- data/lib/mongo/bulk_write/result.rb +194 -0
- data/lib/mongo/bulk_write/result_combiner.rb +133 -0
- data/lib/mongo/bulk_write/transformable.rb +156 -0
- data/lib/mongo/bulk_write/unordered_combiner.rb +55 -0
- data/lib/mongo/bulk_write/validatable.rb +76 -0
- data/lib/mongo/bulk_write.rb +289 -0
- data/lib/mongo/caching_cursor.rb +77 -0
- data/lib/mongo/client.rb +1426 -0
- data/lib/mongo/client_encryption.rb +106 -0
- data/lib/mongo/cluster/periodic_executor.rb +104 -0
- data/lib/mongo/cluster/reapers/cursor_reaper.rb +159 -0
- data/lib/mongo/cluster/reapers/socket_reaper.rb +65 -0
- data/lib/mongo/cluster/sdam_flow.rb +620 -0
- data/lib/mongo/cluster/topology/base.rb +221 -0
- data/lib/mongo/cluster/topology/no_replica_set_options.rb +37 -0
- data/lib/mongo/cluster/topology/replica_set_no_primary.rb +172 -0
- data/lib/mongo/cluster/topology/replica_set_with_primary.rb +30 -0
- data/lib/mongo/cluster/topology/sharded.rb +138 -0
- data/lib/mongo/cluster/topology/single.rb +147 -0
- data/lib/mongo/cluster/topology/unknown.rb +139 -0
- data/lib/mongo/cluster/topology.rb +112 -0
- data/lib/mongo/cluster.rb +988 -0
- data/lib/mongo/cluster_time.rb +142 -0
- data/lib/mongo/collection/view/aggregation.rb +166 -0
- data/lib/mongo/collection/view/builder/aggregation.rb +142 -0
- data/lib/mongo/collection/view/builder/find_command.rb +173 -0
- data/lib/mongo/collection/view/builder/flags.rb +65 -0
- data/lib/mongo/collection/view/builder/map_reduce.rb +173 -0
- data/lib/mongo/collection/view/builder/modifiers.rb +83 -0
- data/lib/mongo/collection/view/builder/op_query.rb +94 -0
- data/lib/mongo/collection/view/builder.rb +23 -0
- data/lib/mongo/collection/view/change_stream/retryable.rb +43 -0
- data/lib/mongo/collection/view/change_stream.rb +372 -0
- data/lib/mongo/collection/view/explainable.rb +86 -0
- data/lib/mongo/collection/view/immutable.rb +39 -0
- data/lib/mongo/collection/view/iterable.rb +182 -0
- data/lib/mongo/collection/view/map_reduce.rb +279 -0
- data/lib/mongo/collection/view/readable.rb +686 -0
- data/lib/mongo/collection/view/writable.rb +474 -0
- data/lib/mongo/collection/view.rb +223 -0
- data/lib/mongo/collection.rb +807 -1016
- data/lib/mongo/crypt/auto_decryption_context.rb +43 -0
- data/lib/mongo/crypt/auto_encrypter.rb +182 -0
- data/lib/mongo/crypt/auto_encryption_context.rb +47 -0
- data/lib/mongo/crypt/binary.rb +158 -0
- data/lib/mongo/crypt/binding.rb +1232 -0
- data/lib/mongo/crypt/context.rb +138 -0
- data/lib/mongo/crypt/data_key_context.rb +165 -0
- data/lib/mongo/crypt/encryption_io.rb +309 -0
- data/lib/mongo/crypt/explicit_decryption_context.rb +43 -0
- data/lib/mongo/crypt/explicit_encrypter.rb +120 -0
- data/lib/mongo/crypt/explicit_encryption_context.rb +92 -0
- data/lib/mongo/crypt/handle.rb +318 -0
- data/lib/mongo/crypt/hooks.rb +93 -0
- data/lib/mongo/crypt/kms_context.rb +70 -0
- data/lib/mongo/crypt/status.rb +134 -0
- data/lib/mongo/crypt.rb +36 -0
- data/lib/mongo/cursor/builder/get_more_command.rb +80 -0
- data/lib/mongo/cursor/builder/kill_cursors_command.rb +111 -0
- data/lib/mongo/cursor/builder/op_get_more.rb +64 -0
- data/lib/mongo/cursor/builder/op_kill_cursors.rb +106 -0
- data/lib/mongo/cursor/builder.rb +21 -0
- data/lib/mongo/cursor.rb +336 -505
- data/lib/mongo/database/view.rb +199 -0
- data/lib/mongo/database.rb +457 -0
- data/lib/mongo/dbref.rb +124 -0
- data/lib/mongo/distinguishing_semaphore.rb +58 -0
- data/lib/mongo/error/auth_error.rb +32 -0
- data/lib/mongo/error/bulk_write_error.rb +76 -0
- data/lib/mongo/error/change_stream_resumable.rb +40 -0
- data/lib/mongo/error/closed_stream.rb +37 -0
- data/lib/mongo/error/connection_check_out_timeout.rb +51 -0
- data/lib/mongo/error/connection_perished.rb +26 -0
- data/lib/mongo/error/credential_check_error.rb +29 -0
- data/lib/mongo/error/crypt_error.rb +34 -0
- data/lib/mongo/error/extra_file_chunk.rb +37 -0
- data/lib/mongo/error/failed_string_prep_validation.rb +41 -0
- data/lib/mongo/error/file_not_found.rb +40 -0
- data/lib/mongo/error/handshake_error.rb +27 -0
- data/lib/mongo/error/insufficient_iteration_count.rb +41 -0
- data/lib/mongo/error/internal_driver_error.rb +25 -0
- data/lib/mongo/error/invalid_address.rb +27 -0
- data/lib/mongo/error/invalid_application_name.rb +41 -0
- data/lib/mongo/error/invalid_bulk_operation.rb +40 -0
- data/lib/mongo/error/invalid_bulk_operation_type.rb +39 -0
- data/lib/mongo/error/invalid_collection_name.rb +42 -0
- data/lib/mongo/error/invalid_cursor_operation.rb +30 -0
- data/lib/mongo/error/invalid_database_name.rb +42 -0
- data/lib/mongo/error/invalid_document.rb +42 -0
- data/lib/mongo/error/invalid_file.rb +41 -0
- data/lib/mongo/error/invalid_file_revision.rb +40 -0
- data/lib/mongo/error/invalid_min_pool_size.rb +38 -0
- data/lib/mongo/error/invalid_nonce.rb +49 -0
- data/lib/mongo/error/invalid_read_concern.rb +31 -0
- data/lib/mongo/error/invalid_read_option.rb +38 -0
- data/lib/mongo/error/invalid_replacement_document.rb +42 -0
- data/lib/mongo/error/invalid_server_auth_host.rb +25 -0
- data/lib/mongo/error/invalid_server_auth_response.rb +26 -0
- data/lib/mongo/error/invalid_server_preference.rb +68 -0
- data/lib/mongo/error/invalid_session.rb +40 -0
- data/lib/mongo/error/invalid_signature.rb +50 -0
- data/lib/mongo/error/invalid_transaction_operation.rb +85 -0
- data/lib/mongo/error/invalid_txt_record.rb +30 -0
- data/lib/mongo/error/invalid_update_document.rb +42 -0
- data/lib/mongo/error/invalid_uri.rb +42 -0
- data/lib/mongo/error/invalid_write_concern.rb +38 -0
- data/lib/mongo/error/kms_error.rb +25 -0
- data/lib/mongo/error/lint_error.rb +38 -0
- data/lib/mongo/error/max_bson_size.rb +54 -0
- data/lib/mongo/error/max_message_size.rb +45 -0
- data/lib/mongo/error/mismatched_domain.rb +30 -0
- data/lib/mongo/error/missing_file_chunk.rb +41 -0
- data/lib/mongo/error/missing_password.rb +32 -0
- data/lib/mongo/error/missing_resume_token.rb +42 -0
- data/lib/mongo/error/missing_scram_server_signature.rb +30 -0
- data/lib/mongo/error/mongocryptd_spawn_error.rb +25 -0
- data/lib/mongo/error/multi_index_drop.rb +37 -0
- data/lib/mongo/error/need_primary_server.rb +26 -0
- data/lib/mongo/error/no_server_available.rb +51 -0
- data/lib/mongo/error/no_srv_records.rb +29 -0
- data/lib/mongo/error/notable.rb +83 -0
- data/lib/mongo/error/operation_failure.rb +311 -0
- data/lib/mongo/error/parser.rb +294 -0
- data/lib/mongo/error/pool_closed_error.rb +53 -0
- data/lib/mongo/error/raise_original_error.rb +32 -0
- data/lib/mongo/error/sdam_error_detection.rb +83 -0
- data/lib/mongo/error/server_api_conflict.rb +26 -0
- data/lib/mongo/error/server_api_not_supported.rb +27 -0
- data/lib/mongo/error/server_certificate_revoked.rb +25 -0
- data/lib/mongo/error/session_ended.rb +30 -0
- data/lib/mongo/error/sessions_not_supported.rb +38 -0
- data/lib/mongo/error/socket_error.rb +29 -0
- data/lib/mongo/error/socket_timeout_error.rb +29 -0
- data/lib/mongo/error/unchangeable_collection_option.rb +41 -0
- data/lib/mongo/error/unexpected_chunk_length.rb +42 -0
- data/lib/mongo/error/unexpected_response.rb +41 -0
- data/lib/mongo/error/unknown_payload_type.rb +44 -0
- data/lib/mongo/error/unmet_dependency.rb +24 -0
- data/lib/mongo/error/unsupported_array_filters.rb +59 -0
- data/lib/mongo/error/unsupported_collation.rb +59 -0
- data/lib/mongo/error/unsupported_features.rb +28 -0
- data/lib/mongo/error/unsupported_message_type.rb +26 -0
- data/lib/mongo/error/unsupported_option.rb +104 -0
- data/lib/mongo/error/write_retryable.rb +30 -0
- data/lib/mongo/error.rb +246 -0
- data/lib/mongo/event/base.rb +45 -0
- data/lib/mongo/event/listeners.rb +66 -0
- data/lib/mongo/event/publisher.rb +45 -0
- data/lib/mongo/event/subscriber.rb +44 -0
- data/lib/mongo/event.rb +50 -0
- data/lib/mongo/grid/file/chunk.rb +191 -0
- data/lib/mongo/grid/file/info.rb +268 -0
- data/lib/mongo/grid/file.rb +124 -0
- data/lib/mongo/grid/fs_bucket.rb +517 -0
- data/lib/mongo/grid/stream/read.rb +244 -0
- data/lib/mongo/grid/stream/write.rb +213 -0
- data/lib/mongo/grid/stream.rb +67 -0
- data/lib/mongo/grid.rb +20 -0
- data/lib/mongo/id.rb +67 -0
- data/lib/mongo/index/view.rb +358 -0
- data/lib/mongo/index.rb +73 -0
- data/lib/mongo/lint.rb +105 -0
- data/lib/mongo/loggable.rb +112 -0
- data/lib/mongo/logger.rb +87 -0
- data/lib/mongo/monitoring/cmap_log_subscriber.rb +56 -0
- data/lib/mongo/monitoring/command_log_subscriber.rb +132 -0
- data/lib/mongo/monitoring/event/cmap/base.rb +31 -0
- data/lib/mongo/monitoring/event/cmap/connection_check_out_failed.rb +88 -0
- data/lib/mongo/monitoring/event/cmap/connection_check_out_started.rb +59 -0
- data/lib/mongo/monitoring/event/cmap/connection_checked_in.rb +74 -0
- data/lib/mongo/monitoring/event/cmap/connection_checked_out.rb +75 -0
- data/lib/mongo/monitoring/event/cmap/connection_closed.rb +106 -0
- data/lib/mongo/monitoring/event/cmap/connection_created.rb +67 -0
- data/lib/mongo/monitoring/event/cmap/connection_ready.rb +67 -0
- data/lib/mongo/monitoring/event/cmap/pool_cleared.rb +60 -0
- data/lib/mongo/monitoring/event/cmap/pool_closed.rb +68 -0
- data/lib/mongo/monitoring/event/cmap/pool_created.rb +75 -0
- data/lib/mongo/monitoring/event/cmap.rb +28 -0
- data/lib/mongo/monitoring/event/command_failed.rb +147 -0
- data/lib/mongo/monitoring/event/command_started.rb +183 -0
- data/lib/mongo/monitoring/event/command_succeeded.rb +157 -0
- data/lib/mongo/monitoring/event/secure.rb +112 -0
- data/lib/mongo/monitoring/event/server_closed.rb +62 -0
- data/lib/mongo/monitoring/event/server_description_changed.rb +99 -0
- data/lib/mongo/monitoring/event/server_heartbeat_failed.rb +92 -0
- data/lib/mongo/monitoring/event/server_heartbeat_started.rb +65 -0
- data/lib/mongo/monitoring/event/server_heartbeat_succeeded.rb +84 -0
- data/lib/mongo/monitoring/event/server_opening.rb +62 -0
- data/lib/mongo/monitoring/event/topology_changed.rb +63 -0
- data/lib/mongo/monitoring/event/topology_closed.rb +57 -0
- data/lib/mongo/monitoring/event/topology_opening.rb +57 -0
- data/lib/mongo/monitoring/event.rb +32 -0
- data/lib/mongo/monitoring/publishable.rb +122 -0
- data/lib/mongo/monitoring/sdam_log_subscriber.rb +57 -0
- data/lib/mongo/monitoring/server_closed_log_subscriber.rb +33 -0
- data/lib/mongo/monitoring/server_description_changed_log_subscriber.rb +44 -0
- data/lib/mongo/monitoring/server_opening_log_subscriber.rb +33 -0
- data/lib/mongo/monitoring/topology_changed_log_subscriber.rb +43 -0
- data/lib/mongo/monitoring/topology_closed_log_subscriber.rb +33 -0
- data/lib/mongo/monitoring/topology_opening_log_subscriber.rb +33 -0
- data/lib/mongo/monitoring/unified_sdam_log_subscriber.rb +65 -0
- data/lib/mongo/monitoring.rb +379 -0
- data/lib/mongo/operation/aggregate/command.rb +47 -0
- data/lib/mongo/operation/aggregate/op_msg.rb +34 -0
- data/lib/mongo/operation/aggregate/result.rb +104 -0
- data/lib/mongo/operation/aggregate.rb +39 -0
- data/lib/mongo/operation/collections_info/command.rb +48 -0
- data/lib/mongo/operation/collections_info/result.rb +59 -0
- data/lib/mongo/operation/collections_info.rb +51 -0
- data/lib/mongo/operation/command/command.rb +41 -0
- data/lib/mongo/operation/command/op_msg.rb +31 -0
- data/lib/mongo/operation/command.rb +34 -0
- data/lib/mongo/operation/context.rb +102 -0
- data/lib/mongo/operation/count/command.rb +41 -0
- data/lib/mongo/operation/count/op_msg.rb +32 -0
- data/lib/mongo/operation/count.rb +34 -0
- data/lib/mongo/operation/create/command.rb +41 -0
- data/lib/mongo/operation/create/op_msg.rb +32 -0
- data/lib/mongo/operation/create.rb +34 -0
- data/lib/mongo/operation/create_index/command.rb +45 -0
- data/lib/mongo/operation/create_index/op_msg.rb +41 -0
- data/lib/mongo/operation/create_index.rb +34 -0
- data/lib/mongo/operation/create_user/command.rb +46 -0
- data/lib/mongo/operation/create_user/op_msg.rb +38 -0
- data/lib/mongo/operation/create_user.rb +34 -0
- data/lib/mongo/operation/delete/bulk_result.rb +51 -0
- data/lib/mongo/operation/delete/command.rb +49 -0
- data/lib/mongo/operation/delete/legacy.rb +57 -0
- data/lib/mongo/operation/delete/op_msg.rb +48 -0
- data/lib/mongo/operation/delete/result.rb +48 -0
- data/lib/mongo/operation/delete.rb +41 -0
- data/lib/mongo/operation/distinct/command.rb +41 -0
- data/lib/mongo/operation/distinct/op_msg.rb +33 -0
- data/lib/mongo/operation/distinct.rb +34 -0
- data/lib/mongo/operation/drop/command.rb +41 -0
- data/lib/mongo/operation/drop/op_msg.rb +32 -0
- data/lib/mongo/operation/drop.rb +34 -0
- data/lib/mongo/operation/drop_database/command.rb +41 -0
- data/lib/mongo/operation/drop_database/op_msg.rb +32 -0
- data/lib/mongo/operation/drop_database.rb +34 -0
- data/lib/mongo/operation/drop_index/command.rb +45 -0
- data/lib/mongo/operation/drop_index/op_msg.rb +38 -0
- data/lib/mongo/operation/drop_index.rb +34 -0
- data/lib/mongo/operation/explain/command.rb +46 -0
- data/lib/mongo/operation/explain/legacy.rb +45 -0
- data/lib/mongo/operation/explain/op_msg.rb +40 -0
- data/lib/mongo/operation/explain/result.rb +56 -0
- data/lib/mongo/operation/explain.rb +36 -0
- data/lib/mongo/operation/find/command.rb +42 -0
- data/lib/mongo/operation/find/legacy/result.rb +46 -0
- data/lib/mongo/operation/find/legacy.rb +43 -0
- data/lib/mongo/operation/find/op_msg.rb +34 -0
- data/lib/mongo/operation/find/result.rb +76 -0
- data/lib/mongo/operation/find.rb +36 -0
- data/lib/mongo/operation/get_more/command.rb +42 -0
- data/lib/mongo/operation/get_more/legacy.rb +39 -0
- data/lib/mongo/operation/get_more/op_msg.rb +33 -0
- data/lib/mongo/operation/get_more/result.rb +75 -0
- data/lib/mongo/operation/get_more.rb +36 -0
- data/lib/mongo/operation/indexes/command.rb +42 -0
- data/lib/mongo/operation/indexes/legacy.rb +48 -0
- data/lib/mongo/operation/indexes/op_msg.rb +34 -0
- data/lib/mongo/operation/indexes/result.rb +105 -0
- data/lib/mongo/operation/indexes.rb +50 -0
- data/lib/mongo/operation/insert/bulk_result.rb +112 -0
- data/lib/mongo/operation/insert/command.rb +59 -0
- data/lib/mongo/operation/insert/legacy.rb +68 -0
- data/lib/mongo/operation/insert/op_msg.rb +54 -0
- data/lib/mongo/operation/insert/result.rb +75 -0
- data/lib/mongo/operation/insert.rb +44 -0
- data/lib/mongo/operation/kill_cursors/command.rb +40 -0
- data/lib/mongo/operation/kill_cursors/legacy.rb +40 -0
- data/lib/mongo/operation/kill_cursors/op_msg.rb +32 -0
- data/lib/mongo/operation/kill_cursors.rb +35 -0
- data/lib/mongo/operation/list_collections/command.rb +46 -0
- data/lib/mongo/operation/list_collections/op_msg.rb +39 -0
- data/lib/mongo/operation/list_collections/result.rb +113 -0
- data/lib/mongo/operation/list_collections.rb +35 -0
- data/lib/mongo/operation/map_reduce/command.rb +43 -0
- data/lib/mongo/operation/map_reduce/op_msg.rb +34 -0
- data/lib/mongo/operation/map_reduce/result.rb +142 -0
- data/lib/mongo/operation/map_reduce.rb +35 -0
- data/lib/mongo/operation/op_msg_base.rb +33 -0
- data/lib/mongo/operation/parallel_scan/command.rb +57 -0
- data/lib/mongo/operation/parallel_scan/op_msg.rb +46 -0
- data/lib/mongo/operation/parallel_scan/result.rb +68 -0
- data/lib/mongo/operation/parallel_scan.rb +35 -0
- data/lib/mongo/operation/remove_user/command.rb +46 -0
- data/lib/mongo/operation/remove_user/op_msg.rb +38 -0
- data/lib/mongo/operation/remove_user.rb +34 -0
- data/lib/mongo/operation/result.rb +461 -0
- data/lib/mongo/operation/shared/bypass_document_validation.rb +46 -0
- data/lib/mongo/operation/shared/causal_consistency_supported.rb +45 -0
- data/lib/mongo/operation/shared/executable.rb +116 -0
- data/lib/mongo/operation/shared/executable_no_validate.rb +32 -0
- data/lib/mongo/operation/shared/executable_transaction_label.rb +30 -0
- data/lib/mongo/operation/shared/idable.rb +68 -0
- data/lib/mongo/operation/shared/limited.rb +42 -0
- data/lib/mongo/operation/shared/object_id_generator.rb +40 -0
- data/lib/mongo/operation/shared/op_msg_or_command.rb +41 -0
- data/lib/mongo/operation/shared/op_msg_or_find_command.rb +44 -0
- data/lib/mongo/operation/shared/polymorphic_lookup.rb +36 -0
- data/lib/mongo/operation/shared/polymorphic_operation.rb +42 -0
- data/lib/mongo/operation/shared/polymorphic_result.rb +50 -0
- data/lib/mongo/operation/shared/read_preference_supported.rb +114 -0
- data/lib/mongo/operation/shared/response_handling.rb +172 -0
- data/lib/mongo/operation/shared/result/aggregatable.rb +74 -0
- data/lib/mongo/operation/shared/result/use_legacy_error_parser.rb +32 -0
- data/lib/mongo/operation/shared/sessions_supported.rb +254 -0
- data/lib/mongo/operation/shared/specifiable.rb +585 -0
- data/lib/mongo/operation/shared/write.rb +90 -0
- data/lib/mongo/operation/shared/write_concern_supported.rb +43 -0
- data/lib/mongo/operation/update/bulk_result.rb +129 -0
- data/lib/mongo/operation/update/command.rb +50 -0
- data/lib/mongo/operation/update/legacy/result.rb +112 -0
- data/lib/mongo/operation/update/legacy.rb +68 -0
- data/lib/mongo/operation/update/op_msg.rb +48 -0
- data/lib/mongo/operation/update/result.rb +113 -0
- data/lib/mongo/operation/update.rb +41 -0
- data/lib/mongo/operation/update_user/command.rb +45 -0
- data/lib/mongo/operation/update_user/op_msg.rb +38 -0
- data/lib/mongo/operation/update_user.rb +34 -0
- data/lib/mongo/operation/users_info/command.rb +46 -0
- data/lib/mongo/operation/users_info/op_msg.rb +39 -0
- data/lib/mongo/operation/users_info/result.rb +48 -0
- data/lib/mongo/operation/users_info.rb +35 -0
- data/lib/mongo/operation.rb +106 -0
- data/lib/mongo/options/mapper.rb +129 -0
- data/lib/mongo/options/redacted.rb +159 -0
- data/lib/mongo/options.rb +19 -0
- data/lib/mongo/protocol/bit_vector.rb +67 -0
- data/lib/mongo/protocol/compressed.rb +184 -0
- data/lib/mongo/protocol/delete.rb +172 -0
- data/lib/mongo/protocol/get_more.rb +165 -0
- data/lib/mongo/protocol/insert.rb +181 -0
- data/lib/mongo/protocol/kill_cursors.rb +133 -0
- data/lib/mongo/protocol/message.rb +465 -0
- data/lib/mongo/protocol/msg.rb +404 -0
- data/lib/mongo/protocol/query.rb +356 -0
- data/lib/mongo/protocol/registry.rb +79 -0
- data/lib/mongo/protocol/reply.rb +207 -0
- data/lib/mongo/protocol/serializers.rb +460 -0
- data/lib/mongo/protocol/update.rb +214 -0
- data/lib/mongo/protocol.rb +21 -0
- data/lib/mongo/query_cache.rb +275 -0
- data/lib/mongo/retryable.rb +496 -0
- data/lib/mongo/semaphore.rb +49 -0
- data/lib/mongo/server/app_metadata.rb +267 -0
- data/lib/mongo/server/connection.rb +326 -0
- data/lib/mongo/server/connection_base.rb +265 -0
- data/lib/mongo/server/connection_common.rb +168 -0
- data/lib/mongo/server/connection_pool/populator.rb +61 -0
- data/lib/mongo/server/connection_pool.rb +802 -0
- data/lib/mongo/server/context.rb +72 -0
- data/lib/mongo/server/description/features.rb +151 -0
- data/lib/mongo/server/description.rb +832 -0
- data/lib/mongo/server/monitor/app_metadata.rb +37 -0
- data/lib/mongo/server/monitor/connection.rb +269 -0
- data/lib/mongo/server/monitor.rb +339 -0
- data/lib/mongo/server/pending_connection.rb +272 -0
- data/lib/mongo/server/push_monitor/connection.rb +31 -0
- data/lib/mongo/server/push_monitor.rb +194 -0
- data/lib/mongo/server/round_trip_time_averager.rb +76 -0
- data/lib/mongo/server.rb +584 -0
- data/lib/mongo/server_selector/base.rb +625 -0
- data/lib/mongo/server_selector/nearest.rb +110 -0
- data/lib/mongo/server_selector/primary.rb +110 -0
- data/lib/mongo/server_selector/primary_preferred.rb +115 -0
- data/lib/mongo/server_selector/secondary.rb +109 -0
- data/lib/mongo/server_selector/secondary_preferred.rb +113 -0
- data/lib/mongo/server_selector.rb +91 -0
- data/lib/mongo/session/server_session.rb +122 -0
- data/lib/mongo/session/session_pool.rb +155 -0
- data/lib/mongo/session.rb +1074 -0
- data/lib/mongo/socket/ocsp_cache.rb +100 -0
- data/lib/mongo/socket/ocsp_verifier.rb +376 -0
- data/lib/mongo/socket/ssl.rb +395 -0
- data/lib/mongo/socket/tcp.rb +97 -0
- data/lib/mongo/socket/unix.rb +63 -0
- data/lib/mongo/socket.rb +463 -0
- data/lib/mongo/srv/monitor.rb +113 -0
- data/lib/mongo/srv/resolver.rb +137 -0
- data/lib/mongo/srv/result.rb +128 -0
- data/lib/mongo/srv.rb +20 -0
- data/lib/mongo/timeout.rb +54 -0
- data/lib/mongo/topology_version.rb +92 -0
- data/lib/mongo/uri/options_mapper.rb +623 -0
- data/lib/mongo/uri/srv_protocol.rb +241 -0
- data/lib/mongo/uri.rb +528 -0
- data/lib/mongo/utils.rb +118 -0
- data/lib/mongo/version.rb +24 -0
- data/lib/mongo/write_concern/acknowledged.rb +65 -0
- data/lib/mongo/write_concern/base.rb +70 -0
- data/lib/mongo/write_concern/unacknowledged.rb +68 -0
- data/lib/mongo/write_concern.rb +99 -0
- data/lib/mongo.rb +98 -71
- data/mongo.gemspec +29 -18
- data/spec/NOTES.aws-auth.md +296 -0
- data/spec/README.aws-auth.md +318 -0
- data/spec/README.md +715 -0
- data/spec/USERS.md +72 -0
- data/spec/atlas/atlas_connectivity_spec.rb +27 -0
- data/spec/atlas/operations_spec.rb +28 -0
- data/spec/integration/auth_spec.rb +279 -0
- data/spec/integration/awaited_ismaster_spec.rb +31 -0
- data/spec/integration/aws_auth_request_spec.rb +77 -0
- data/spec/integration/aws_credentials_retriever_spec.rb +106 -0
- data/spec/integration/bson_symbol_spec.rb +39 -0
- data/spec/integration/bulk_insert_spec.rb +83 -0
- data/spec/integration/bulk_write_error_message_spec.rb +41 -0
- data/spec/integration/bulk_write_spec.rb +70 -0
- data/spec/integration/change_stream_examples_spec.rb +208 -0
- data/spec/integration/change_stream_spec.rb +808 -0
- data/spec/integration/check_clean_slate_spec.rb +19 -0
- data/spec/integration/client_authentication_options_spec.rb +514 -0
- data/spec/integration/client_connectivity_spec.rb +41 -0
- data/spec/integration/client_construction_aws_auth_spec.rb +194 -0
- data/spec/integration/client_construction_spec.rb +239 -0
- data/spec/integration/client_side_encryption/auto_encryption_bulk_writes_spec.rb +360 -0
- data/spec/integration/client_side_encryption/auto_encryption_command_monitoring_spec.rb +306 -0
- data/spec/integration/client_side_encryption/auto_encryption_mongocryptd_spawn_spec.rb +75 -0
- data/spec/integration/client_side_encryption/auto_encryption_old_wire_version_spec.rb +82 -0
- data/spec/integration/client_side_encryption/auto_encryption_reconnect_spec.rb +224 -0
- data/spec/integration/client_side_encryption/auto_encryption_spec.rb +604 -0
- data/spec/integration/client_side_encryption/bson_size_limit_spec.rb +190 -0
- data/spec/integration/client_side_encryption/bypass_mongocryptd_spawn_spec.rb +81 -0
- data/spec/integration/client_side_encryption/client_close_spec.rb +66 -0
- data/spec/integration/client_side_encryption/corpus_spec.rb +236 -0
- data/spec/integration/client_side_encryption/custom_endpoint_spec.rb +135 -0
- data/spec/integration/client_side_encryption/data_key_spec.rb +168 -0
- data/spec/integration/client_side_encryption/explicit_encryption_spec.rb +117 -0
- data/spec/integration/client_side_encryption/external_key_vault_spec.rb +144 -0
- data/spec/integration/client_side_encryption/views_spec.rb +47 -0
- data/spec/integration/client_spec.rb +47 -0
- data/spec/integration/client_update_spec.rb +157 -0
- data/spec/integration/collection_indexes_prose_spec.rb +58 -0
- data/spec/integration/command_monitoring_spec.rb +184 -0
- data/spec/integration/command_spec.rb +179 -0
- data/spec/integration/connect_single_rs_name_spec.rb +75 -0
- data/spec/integration/connection_pool_populator_spec.rb +305 -0
- data/spec/integration/connection_spec.rb +336 -0
- data/spec/integration/crud_spec.rb +193 -0
- data/spec/integration/cursor_reaping_spec.rb +139 -0
- data/spec/integration/docs_examples_spec.rb +207 -0
- data/spec/integration/error_detection_spec.rb +42 -0
- data/spec/integration/fork_reconnect_spec.rb +204 -0
- data/spec/integration/get_more_spec.rb +42 -0
- data/spec/integration/grid_fs_bucket_spec.rb +51 -0
- data/spec/integration/heartbeat_events_spec.rb +102 -0
- data/spec/integration/mmapv1_spec.rb +31 -0
- data/spec/integration/mongos_pinning_spec.rb +37 -0
- data/spec/integration/ocsp_connectivity_spec.rb +29 -0
- data/spec/integration/ocsp_verifier_cache_spec.rb +191 -0
- data/spec/integration/ocsp_verifier_spec.rb +355 -0
- data/spec/integration/operation_failure_code_spec.rb +29 -0
- data/spec/integration/operation_failure_message_spec.rb +90 -0
- data/spec/integration/query_cache_spec.rb +1093 -0
- data/spec/integration/query_cache_transactions_spec.rb +193 -0
- data/spec/integration/read_concern_spec.rb +92 -0
- data/spec/integration/read_preference_spec.rb +544 -0
- data/spec/integration/reconnect_spec.rb +177 -0
- data/spec/integration/retryable_errors_spec.rb +286 -0
- data/spec/integration/retryable_writes/retryable_writes_36_and_older_spec.rb +764 -0
- data/spec/integration/retryable_writes/retryable_writes_40_and_newer_spec.rb +405 -0
- data/spec/integration/retryable_writes/shared/adds_diagnostics.rb +18 -0
- data/spec/integration/retryable_writes/shared/does_not_support_retries.rb +27 -0
- data/spec/integration/retryable_writes/shared/only_supports_legacy_retries.rb +28 -0
- data/spec/integration/retryable_writes/shared/performs_legacy_retries.rb +220 -0
- data/spec/integration/retryable_writes/shared/performs_modern_retries.rb +235 -0
- data/spec/integration/retryable_writes/shared/performs_no_retries.rb +113 -0
- data/spec/integration/retryable_writes/shared/supports_legacy_retries.rb +22 -0
- data/spec/integration/retryable_writes/shared/supports_modern_retries.rb +28 -0
- data/spec/integration/retryable_writes/shared/supports_retries.rb +19 -0
- data/spec/integration/retryable_writes_errors_spec.rb +34 -0
- data/spec/integration/sdam_error_handling_spec.rb +424 -0
- data/spec/integration/sdam_events_spec.rb +122 -0
- data/spec/integration/sdam_prose_spec.rb +67 -0
- data/spec/integration/secondary_reads_spec.rb +102 -0
- data/spec/integration/server_description_spec.rb +48 -0
- data/spec/integration/server_monitor_spec.rb +55 -0
- data/spec/integration/server_selection_spec.rb +39 -0
- data/spec/integration/server_selector_spec.rb +88 -0
- data/spec/integration/server_spec.rb +67 -0
- data/spec/integration/shell_examples_spec.rb +984 -0
- data/spec/integration/size_limit_spec.rb +115 -0
- data/spec/integration/snappy_compression_spec.rb +28 -0
- data/spec/integration/srv_monitoring_spec.rb +406 -0
- data/spec/integration/srv_spec.rb +59 -0
- data/spec/integration/ssl_uri_options_spec.rb +28 -0
- data/spec/integration/step_down_spec.rb +207 -0
- data/spec/integration/time_zone_querying_spec.rb +55 -0
- data/spec/integration/transactions_api_examples_spec.rb +62 -0
- data/spec/integration/transactions_examples_spec.rb +235 -0
- data/spec/integration/truncated_utf8_spec.rb +26 -0
- data/spec/integration/versioned_api_examples_spec.rb +69 -0
- data/spec/integration/x509_auth_spec.rb +112 -0
- data/spec/integration/zlib_compression_spec.rb +28 -0
- data/spec/integration/zstd_compression_spec.rb +29 -0
- data/spec/kerberos/kerberos_spec.rb +94 -0
- data/spec/lite_spec_helper.rb +168 -0
- data/spec/mongo/address/ipv4_spec.rb +102 -0
- data/spec/mongo/address/ipv6_spec.rb +130 -0
- data/spec/mongo/address/unix_spec.rb +44 -0
- data/spec/mongo/address/validator_spec.rb +54 -0
- data/spec/mongo/address_spec.rb +344 -0
- data/spec/mongo/auth/aws/request_region_spec.rb +45 -0
- data/spec/mongo/auth/aws/request_spec.rb +79 -0
- data/spec/mongo/auth/cr_spec.rb +79 -0
- data/spec/mongo/auth/gssapi/conversation_spec.rb +124 -0
- data/spec/mongo/auth/invalid_mechanism_spec.rb +14 -0
- data/spec/mongo/auth/ldap/conversation_spec.rb +46 -0
- data/spec/mongo/auth/ldap_spec.rb +47 -0
- data/spec/mongo/auth/scram/conversation_spec.rb +205 -0
- data/spec/mongo/auth/scram256/conversation_spec.rb +174 -0
- data/spec/mongo/auth/scram_negotiation_spec.rb +531 -0
- data/spec/mongo/auth/scram_spec.rb +122 -0
- data/spec/mongo/auth/stringprep/profiles/sasl_spec.rb +116 -0
- data/spec/mongo/auth/stringprep_spec.rb +191 -0
- data/spec/mongo/auth/user/view_spec.rb +489 -0
- data/spec/mongo/auth/user_spec.rb +343 -0
- data/spec/mongo/auth/x509/conversation_spec.rb +72 -0
- data/spec/mongo/auth/x509_spec.rb +73 -0
- data/spec/mongo/auth_spec.rb +68 -0
- data/spec/mongo/bson_spec.rb +14 -0
- data/spec/mongo/bulk_write/ordered_combiner_spec.rb +287 -0
- data/spec/mongo/bulk_write/result_spec.rb +127 -0
- data/spec/mongo/bulk_write/unordered_combiner_spec.rb +242 -0
- data/spec/mongo/bulk_write_spec.rb +2393 -0
- data/spec/mongo/caching_cursor_spec.rb +73 -0
- data/spec/mongo/client_construction_spec.rb +2389 -0
- data/spec/mongo/client_encryption_spec.rb +414 -0
- data/spec/mongo/client_spec.rb +964 -0
- data/spec/mongo/cluster/cursor_reaper_spec.rb +190 -0
- data/spec/mongo/cluster/periodic_executor_spec.rb +19 -0
- data/spec/mongo/cluster/socket_reaper_spec.rb +46 -0
- data/spec/mongo/cluster/topology/replica_set_spec.rb +601 -0
- data/spec/mongo/cluster/topology/sharded_spec.rb +158 -0
- data/spec/mongo/cluster/topology/single_spec.rb +192 -0
- data/spec/mongo/cluster/topology/unknown_spec.rb +103 -0
- data/spec/mongo/cluster/topology_spec.rb +211 -0
- data/spec/mongo/cluster_spec.rb +790 -0
- data/spec/mongo/cluster_time_spec.rb +151 -0
- data/spec/mongo/collection/view/aggregation_spec.rb +678 -0
- data/spec/mongo/collection/view/builder/find_command_spec.rb +524 -0
- data/spec/mongo/collection/view/builder/flags_spec.rb +109 -0
- data/spec/mongo/collection/view/builder/modifiers_spec.rb +213 -0
- data/spec/mongo/collection/view/builder/op_query_spec.rb +157 -0
- data/spec/mongo/collection/view/change_stream_resume_spec.rb +397 -0
- data/spec/mongo/collection/view/change_stream_spec.rb +547 -0
- data/spec/mongo/collection/view/explainable_spec.rb +117 -0
- data/spec/mongo/collection/view/immutable_spec.rb +57 -0
- data/spec/mongo/collection/view/iterable_spec.rb +41 -0
- data/spec/mongo/collection/view/map_reduce_spec.rb +868 -0
- data/spec/mongo/collection/view/readable_spec.rb +1485 -0
- data/spec/mongo/collection/view/writable_spec.rb +1864 -0
- data/spec/mongo/collection/view_spec.rb +424 -0
- data/spec/mongo/collection_crud_spec.rb +4360 -0
- data/spec/mongo/collection_ddl_spec.rb +537 -0
- data/spec/mongo/collection_spec.rb +804 -0
- data/spec/mongo/crypt/auto_decryption_context_spec.rb +93 -0
- data/spec/mongo/crypt/auto_encrypter_spec.rb +190 -0
- data/spec/mongo/crypt/auto_encryption_context_spec.rb +110 -0
- data/spec/mongo/crypt/binary_spec.rb +113 -0
- data/spec/mongo/crypt/binding/binary_spec.rb +54 -0
- data/spec/mongo/crypt/binding/context_spec.rb +255 -0
- data/spec/mongo/crypt/binding/helpers_spec.rb +44 -0
- data/spec/mongo/crypt/binding/mongocrypt_spec.rb +142 -0
- data/spec/mongo/crypt/binding/status_spec.rb +97 -0
- data/spec/mongo/crypt/binding/version_spec.rb +20 -0
- data/spec/mongo/crypt/binding_unloaded_spec.rb +23 -0
- data/spec/mongo/crypt/data_key_context_spec.rb +216 -0
- data/spec/mongo/crypt/encryption_io_spec.rb +139 -0
- data/spec/mongo/crypt/explicit_decryption_context_spec.rb +75 -0
- data/spec/mongo/crypt/explicit_encryption_context_spec.rb +173 -0
- data/spec/mongo/crypt/handle_spec.rb +235 -0
- data/spec/mongo/crypt/helpers/mongo_crypt_spec_helper.rb +111 -0
- data/spec/mongo/crypt/status_spec.rb +150 -0
- data/spec/mongo/cursor/builder/get_more_command_spec.rb +191 -0
- data/spec/mongo/cursor/builder/op_get_more_spec.rb +64 -0
- data/spec/mongo/cursor/builder/op_kill_cursors_spec.rb +66 -0
- data/spec/mongo/cursor_spec.rb +690 -0
- data/spec/mongo/database_spec.rb +1300 -0
- data/spec/mongo/dbref_spec.rb +152 -0
- data/spec/mongo/distinguishing_semaphore_spec.rb +66 -0
- data/spec/mongo/error/bulk_write_error_spec.rb +52 -0
- data/spec/mongo/error/crypt_error_spec.rb +29 -0
- data/spec/mongo/error/max_bson_size_spec.rb +38 -0
- data/spec/mongo/error/no_server_available_spec.rb +35 -0
- data/spec/mongo/error/notable_spec.rb +62 -0
- data/spec/mongo/error/operation_failure_heavy_spec.rb +61 -0
- data/spec/mongo/error/operation_failure_spec.rb +553 -0
- data/spec/mongo/error/parser_spec.rb +519 -0
- data/spec/mongo/error/unsupported_option_spec.rb +57 -0
- data/spec/mongo/event/publisher_spec.rb +53 -0
- data/spec/mongo/event/subscriber_spec.rb +37 -0
- data/spec/mongo/grid/file/chunk_spec.rb +230 -0
- data/spec/mongo/grid/file/info_spec.rb +107 -0
- data/spec/mongo/grid/file_spec.rb +194 -0
- data/spec/mongo/grid/fs_bucket_spec.rb +1263 -0
- data/spec/mongo/grid/stream/read_spec.rb +292 -0
- data/spec/mongo/grid/stream/write_spec.rb +565 -0
- data/spec/mongo/grid/stream_spec.rb +51 -0
- data/spec/mongo/id_spec.rb +38 -0
- data/spec/mongo/index/view_spec.rb +1171 -0
- data/spec/mongo/lint_spec.rb +231 -0
- data/spec/mongo/logger_spec.rb +62 -0
- data/spec/mongo/monitoring/command_log_subscriber_spec.rb +79 -0
- data/spec/mongo/monitoring/event/cmap/connection_check_out_failed_spec.rb +26 -0
- data/spec/mongo/monitoring/event/cmap/connection_check_out_started_spec.rb +22 -0
- data/spec/mongo/monitoring/event/cmap/connection_checked_in_spec.rb +33 -0
- data/spec/mongo/monitoring/event/cmap/connection_checked_out_spec.rb +33 -0
- data/spec/mongo/monitoring/event/cmap/connection_closed_spec.rb +30 -0
- data/spec/mongo/monitoring/event/cmap/connection_created_spec.rb +27 -0
- data/spec/mongo/monitoring/event/cmap/connection_ready_spec.rb +27 -0
- data/spec/mongo/monitoring/event/cmap/pool_cleared_spec.rb +22 -0
- data/spec/mongo/monitoring/event/cmap/pool_closed_spec.rb +29 -0
- data/spec/mongo/monitoring/event/cmap/pool_created_spec.rb +36 -0
- data/spec/mongo/monitoring/event/command_failed_spec.rb +87 -0
- data/spec/mongo/monitoring/event/command_started_spec.rb +51 -0
- data/spec/mongo/monitoring/event/command_succeeded_spec.rb +88 -0
- data/spec/mongo/monitoring/event/secure_spec.rb +123 -0
- data/spec/mongo/monitoring/event/server_closed_spec.rb +38 -0
- data/spec/mongo/monitoring/event/server_description_changed_spec.rb +38 -0
- data/spec/mongo/monitoring/event/server_heartbeat_failed_spec.rb +34 -0
- data/spec/mongo/monitoring/event/server_heartbeat_started_spec.rb +34 -0
- data/spec/mongo/monitoring/event/server_heartbeat_succeeded_spec.rb +34 -0
- data/spec/mongo/monitoring/event/server_opening_spec.rb +38 -0
- data/spec/mongo/monitoring/event/topology_changed_spec.rb +44 -0
- data/spec/mongo/monitoring/event/topology_closed_spec.rb +38 -0
- data/spec/mongo/monitoring/event/topology_opening_spec.rb +38 -0
- data/spec/mongo/monitoring_spec.rb +196 -0
- data/spec/mongo/operation/aggregate/result_spec.rb +90 -0
- data/spec/mongo/operation/aggregate_spec.rb +76 -0
- data/spec/mongo/operation/collections_info_spec.rb +48 -0
- data/spec/mongo/operation/command_spec.rb +86 -0
- data/spec/mongo/operation/create_index_spec.rb +62 -0
- data/spec/mongo/operation/create_user_spec.rb +53 -0
- data/spec/mongo/operation/delete/bulk_spec.rb +245 -0
- data/spec/mongo/operation/delete/command_spec.rb +115 -0
- data/spec/mongo/operation/delete/op_msg_spec.rb +257 -0
- data/spec/mongo/operation/delete_spec.rb +233 -0
- data/spec/mongo/operation/drop_index_spec.rb +61 -0
- data/spec/mongo/operation/find/legacy_spec.rb +130 -0
- data/spec/mongo/operation/get_more_spec.rb +63 -0
- data/spec/mongo/operation/indexes_spec.rb +41 -0
- data/spec/mongo/operation/insert/bulk_spec.rb +273 -0
- data/spec/mongo/operation/insert/command_spec.rb +118 -0
- data/spec/mongo/operation/insert/op_msg_spec.rb +288 -0
- data/spec/mongo/operation/insert_spec.rb +290 -0
- data/spec/mongo/operation/kill_cursors_spec.rb +44 -0
- data/spec/mongo/operation/limited_spec.rb +55 -0
- data/spec/mongo/operation/map_reduce_spec.rb +131 -0
- data/spec/mongo/operation/read_preference_legacy_spec.rb +356 -0
- data/spec/mongo/operation/read_preference_op_msg_spec.rb +307 -0
- data/spec/mongo/operation/remove_user_spec.rb +52 -0
- data/spec/mongo/operation/result_spec.rb +349 -0
- data/spec/mongo/operation/specifiable_spec.rb +87 -0
- data/spec/mongo/operation/update/bulk_spec.rb +239 -0
- data/spec/mongo/operation/update/command_spec.rb +122 -0
- data/spec/mongo/operation/update/op_msg_spec.rb +263 -0
- data/spec/mongo/operation/update_spec.rb +264 -0
- data/spec/mongo/operation/update_user_spec.rb +52 -0
- data/spec/mongo/options/redacted_spec.rb +353 -0
- data/spec/mongo/protocol/compressed_spec.rb +83 -0
- data/spec/mongo/protocol/delete_spec.rb +185 -0
- data/spec/mongo/protocol/get_more_spec.rb +164 -0
- data/spec/mongo/protocol/insert_spec.rb +179 -0
- data/spec/mongo/protocol/kill_cursors_spec.rb +121 -0
- data/spec/mongo/protocol/msg_spec.rb +528 -0
- data/spec/mongo/protocol/query_spec.rb +347 -0
- data/spec/mongo/protocol/registry_spec.rb +34 -0
- data/spec/mongo/protocol/reply_spec.rb +198 -0
- data/spec/mongo/protocol/update_spec.rb +204 -0
- data/spec/mongo/query_cache_middleware_spec.rb +55 -0
- data/spec/mongo/query_cache_spec.rb +283 -0
- data/spec/mongo/retryable_spec.rb +592 -0
- data/spec/mongo/semaphore_spec.rb +54 -0
- data/spec/mongo/server/app_metadata_spec.rb +170 -0
- data/spec/mongo/server/connection_auth_spec.rb +136 -0
- data/spec/mongo/server/connection_common_spec.rb +24 -0
- data/spec/mongo/server/connection_pool/populator_spec.rb +106 -0
- data/spec/mongo/server/connection_pool_spec.rb +1039 -0
- data/spec/mongo/server/connection_spec.rb +1285 -0
- data/spec/mongo/server/description/features_spec.rb +250 -0
- data/spec/mongo/server/description_query_methods_spec.rb +291 -0
- data/spec/mongo/server/description_spec.rb +846 -0
- data/spec/mongo/server/monitor/app_metadata_spec.rb +25 -0
- data/spec/mongo/server/monitor/connection_spec.rb +175 -0
- data/spec/mongo/server/monitor_spec.rb +324 -0
- data/spec/mongo/server/round_trip_time_averager_spec.rb +48 -0
- data/spec/mongo/server_selector/nearest_spec.rb +338 -0
- data/spec/mongo/server_selector/primary_preferred_spec.rb +372 -0
- data/spec/mongo/server_selector/primary_spec.rb +181 -0
- data/spec/mongo/server_selector/secondary_preferred_spec.rb +350 -0
- data/spec/mongo/server_selector/secondary_spec.rb +278 -0
- data/spec/mongo/server_selector_spec.rb +615 -0
- data/spec/mongo/server_spec.rb +436 -0
- data/spec/mongo/session/server_session_spec.rb +62 -0
- data/spec/mongo/session/session_pool_spec.rb +240 -0
- data/spec/mongo/session_spec.rb +348 -0
- data/spec/mongo/session_transaction_spec.rb +221 -0
- data/spec/mongo/socket/ssl_spec.rb +867 -0
- data/spec/mongo/socket/tcp_spec.rb +17 -0
- data/spec/mongo/socket/unix_spec.rb +55 -0
- data/spec/mongo/socket_spec.rb +119 -0
- data/spec/mongo/srv/monitor_spec.rb +233 -0
- data/spec/mongo/srv/result_spec.rb +57 -0
- data/spec/mongo/timeout_spec.rb +42 -0
- data/spec/mongo/tls_context_hooks_spec.rb +40 -0
- data/spec/mongo/uri/srv_protocol_spec.rb +1108 -0
- data/spec/mongo/uri_option_parsing_spec.rb +592 -0
- data/spec/mongo/uri_spec.rb +1286 -0
- data/spec/mongo/utils_spec.rb +56 -0
- data/spec/mongo/write_concern/acknowledged_spec.rb +58 -0
- data/spec/mongo/write_concern/unacknowledged_spec.rb +29 -0
- data/spec/mongo/write_concern_spec.rb +227 -0
- data/spec/runners/auth.rb +140 -0
- data/spec/runners/change_streams/outcome.rb +45 -0
- data/spec/runners/change_streams/spec.rb +60 -0
- data/spec/runners/change_streams/test.rb +232 -0
- data/spec/runners/cmap/verifier.rb +48 -0
- data/spec/runners/cmap.rb +373 -0
- data/spec/runners/command_monitoring.rb +346 -0
- data/spec/runners/connection_string.rb +381 -0
- data/spec/runners/crud/context.rb +30 -0
- data/spec/runners/crud/operation.rb +469 -0
- data/spec/runners/crud/outcome.rb +56 -0
- data/spec/runners/crud/requirement.rb +133 -0
- data/spec/runners/crud/spec.rb +73 -0
- data/spec/runners/crud/test.rb +123 -0
- data/spec/runners/crud/test_base.rb +53 -0
- data/spec/runners/crud/verifier.rb +217 -0
- data/spec/runners/crud.rb +257 -0
- data/spec/runners/gridfs.rb +641 -0
- data/spec/runners/read_write_concern_document.rb +70 -0
- data/spec/runners/sdam/verifier.rb +112 -0
- data/spec/runners/sdam.rb +278 -0
- data/spec/runners/server_selection.rb +365 -0
- data/spec/runners/server_selection_rtt.rb +41 -0
- data/spec/runners/transactions/operation.rb +328 -0
- data/spec/runners/transactions/spec.rb +29 -0
- data/spec/runners/transactions/test.rb +326 -0
- data/spec/runners/transactions.rb +104 -0
- data/spec/runners/unified/assertions.rb +282 -0
- data/spec/runners/unified/change_stream_operations.rb +29 -0
- data/spec/runners/unified/crud_operations.rb +206 -0
- data/spec/runners/unified/ddl_operations.rb +106 -0
- data/spec/runners/unified/entity_map.rb +42 -0
- data/spec/runners/unified/error.rb +28 -0
- data/spec/runners/unified/event_subscriber.rb +104 -0
- data/spec/runners/unified/exceptions.rb +24 -0
- data/spec/runners/unified/grid_fs_operations.rb +58 -0
- data/spec/runners/unified/support_operations.rb +253 -0
- data/spec/runners/unified/test.rb +423 -0
- data/spec/runners/unified/test_group.rb +31 -0
- data/spec/runners/unified/using_hash.rb +34 -0
- data/spec/runners/unified.rb +99 -0
- data/spec/shared/LICENSE +20 -0
- data/spec/shared/bin/get-mongodb-download-url +17 -0
- data/spec/shared/bin/s3-copy +45 -0
- data/spec/shared/bin/s3-upload +69 -0
- data/spec/shared/lib/mrss/child_process_helper.rb +80 -0
- data/spec/shared/lib/mrss/cluster_config.rb +226 -0
- data/spec/shared/lib/mrss/constraints.rb +379 -0
- data/spec/shared/lib/mrss/docker_runner.rb +271 -0
- data/spec/shared/lib/mrss/lite_constraints.rb +191 -0
- data/spec/shared/lib/mrss/server_version_registry.rb +115 -0
- data/spec/shared/lib/mrss/spec_organizer.rb +179 -0
- data/spec/shared/lib/mrss/utils.rb +15 -0
- data/spec/shared/share/Dockerfile.erb +322 -0
- data/spec/shared/share/haproxy-1.conf +16 -0
- data/spec/shared/share/haproxy-2.conf +17 -0
- data/spec/shared/shlib/distro.sh +73 -0
- data/spec/shared/shlib/server.sh +317 -0
- data/spec/shared/shlib/set_env.sh +131 -0
- data/spec/solo/clean_exit_spec.rb +24 -0
- data/spec/spec_helper.rb +36 -0
- data/spec/spec_tests/auth_spec.rb +58 -0
- data/spec/spec_tests/change_streams_spec.rb +93 -0
- data/spec/spec_tests/change_streams_unified_spec.rb +13 -0
- data/spec/spec_tests/client_side_encryption_spec.rb +14 -0
- data/spec/spec_tests/cmap_spec.rb +109 -0
- data/spec/spec_tests/collection_management_spec.rb +13 -0
- data/spec/spec_tests/command_monitoring_spec.rb +71 -0
- data/spec/spec_tests/command_monitoring_unified_spec.rb +13 -0
- data/spec/spec_tests/connection_string_spec.rb +10 -0
- data/spec/spec_tests/crud_spec.rb +22 -0
- data/spec/spec_tests/crud_unified_spec.rb +13 -0
- data/spec/spec_tests/data/auth/connection-string.yml +366 -0
- data/spec/spec_tests/data/change_streams/change-streams-errors.yml +101 -0
- data/spec/spec_tests/data/change_streams/change-streams-resume-allowlist.yml +1173 -0
- data/spec/spec_tests/data/change_streams/change-streams-resume-errorLabels.yml +1105 -0
- data/spec/spec_tests/data/change_streams/change-streams.yml +535 -0
- data/spec/spec_tests/data/change_streams_unified/change-streams.yml +72 -0
- data/spec/spec_tests/data/client_side_encryption/aggregate.yml +134 -0
- data/spec/spec_tests/data/client_side_encryption/badQueries.yml +526 -0
- data/spec/spec_tests/data/client_side_encryption/badSchema.yml +73 -0
- data/spec/spec_tests/data/client_side_encryption/basic.yml +116 -0
- data/spec/spec_tests/data/client_side_encryption/bulk.yml +88 -0
- data/spec/spec_tests/data/client_side_encryption/bypassAutoEncryption.yml +100 -0
- data/spec/spec_tests/data/client_side_encryption/bypassedCommand.yml +42 -0
- data/spec/spec_tests/data/client_side_encryption/count.yml +61 -0
- data/spec/spec_tests/data/client_side_encryption/countDocuments.yml +59 -0
- data/spec/spec_tests/data/client_side_encryption/delete.yml +105 -0
- data/spec/spec_tests/data/client_side_encryption/distinct.yml +73 -0
- data/spec/spec_tests/data/client_side_encryption/explain.yml +64 -0
- data/spec/spec_tests/data/client_side_encryption/find.yml +119 -0
- data/spec/spec_tests/data/client_side_encryption/findOneAndDelete.yml +57 -0
- data/spec/spec_tests/data/client_side_encryption/findOneAndReplace.yml +57 -0
- data/spec/spec_tests/data/client_side_encryption/findOneAndUpdate.yml +57 -0
- data/spec/spec_tests/data/client_side_encryption/getMore.yml +68 -0
- data/spec/spec_tests/data/client_side_encryption/insert.yml +102 -0
- data/spec/spec_tests/data/client_side_encryption/keyAltName.yml +71 -0
- data/spec/spec_tests/data/client_side_encryption/localKMS.yml +54 -0
- data/spec/spec_tests/data/client_side_encryption/localSchema.yml +72 -0
- data/spec/spec_tests/data/client_side_encryption/malformedCiphertext.yml +69 -0
- data/spec/spec_tests/data/client_side_encryption/maxWireVersion.yml +20 -0
- data/spec/spec_tests/data/client_side_encryption/missingKey.yml +49 -0
- data/spec/spec_tests/data/client_side_encryption/replaceOne.yml +64 -0
- data/spec/spec_tests/data/client_side_encryption/types.yml +527 -0
- data/spec/spec_tests/data/client_side_encryption/unsupportedCommand.yml +25 -0
- data/spec/spec_tests/data/client_side_encryption/updateMany.yml +77 -0
- data/spec/spec_tests/data/client_side_encryption/updateOne.yml +171 -0
- data/spec/spec_tests/data/cmap/connection-must-have-id.yml +27 -0
- data/spec/spec_tests/data/cmap/connection-must-order-ids.yml +27 -0
- data/spec/spec_tests/data/cmap/pool-checkin-destroy-closed.yml +27 -0
- data/spec/spec_tests/data/cmap/pool-checkin-destroy-stale.yml +27 -0
- data/spec/spec_tests/data/cmap/pool-checkin-make-available.yml +24 -0
- data/spec/spec_tests/data/cmap/pool-checkin.yml +19 -0
- data/spec/spec_tests/data/cmap/pool-checkout-connection.yml +19 -0
- data/spec/spec_tests/data/cmap/pool-checkout-error-closed.yml +36 -0
- data/spec/spec_tests/data/cmap/pool-checkout-multiple.yml +37 -0
- data/spec/spec_tests/data/cmap/pool-checkout-no-idle.yml +35 -0
- data/spec/spec_tests/data/cmap/pool-checkout-no-stale.yml +33 -0
- data/spec/spec_tests/data/cmap/pool-close-destroy-conns.yml +28 -0
- data/spec/spec_tests/data/cmap/pool-close.yml +11 -0
- data/spec/spec_tests/data/cmap/pool-create-max-size.yml +71 -0
- data/spec/spec_tests/data/cmap/pool-create-min-size.yml +34 -0
- data/spec/spec_tests/data/cmap/pool-create-with-options.yml +21 -0
- data/spec/spec_tests/data/cmap/pool-create.yml +12 -0
- data/spec/spec_tests/data/cmap/wait-queue-fairness.yml +124 -0
- data/spec/spec_tests/data/cmap/wait-queue-timeout.yml +46 -0
- data/spec/spec_tests/data/collection_management/timeseries-collection.yml +129 -0
- data/spec/spec_tests/data/command_monitoring/bulkWrite.yml +49 -0
- data/spec/spec_tests/data/command_monitoring/command.yml +61 -0
- data/spec/spec_tests/data/command_monitoring/deleteMany.yml +55 -0
- data/spec/spec_tests/data/command_monitoring/deleteOne.yml +55 -0
- data/spec/spec_tests/data/command_monitoring/find.yml +266 -0
- data/spec/spec_tests/data/command_monitoring/insertMany.yml +75 -0
- data/spec/spec_tests/data/command_monitoring/insertOne.yml +51 -0
- data/spec/spec_tests/data/command_monitoring/unacknowledgedBulkWrite.yml +34 -0
- data/spec/spec_tests/data/command_monitoring/updateMany.yml +65 -0
- data/spec/spec_tests/data/command_monitoring/updateOne.yml +90 -0
- data/spec/spec_tests/data/command_monitoring_unified/redacted-commands.yml +340 -0
- data/spec/spec_tests/data/connection_string/invalid-uris.yml +261 -0
- data/spec/spec_tests/data/connection_string/valid-auth.yml +257 -0
- data/spec/spec_tests/data/connection_string/valid-db-with-dotted-name.yml +77 -0
- data/spec/spec_tests/data/connection_string/valid-host_identifiers.yml +121 -0
- data/spec/spec_tests/data/connection_string/valid-options.yml +17 -0
- data/spec/spec_tests/data/connection_string/valid-unix_socket-absolute.yml +197 -0
- data/spec/spec_tests/data/connection_string/valid-unix_socket-relative.yml +213 -0
- data/spec/spec_tests/data/connection_string/valid-warnings.yml +75 -0
- data/spec/spec_tests/data/crud/read/aggregate-collation.yml +17 -0
- data/spec/spec_tests/data/crud/read/aggregate-out.yml +43 -0
- data/spec/spec_tests/data/crud/read/aggregate.yml +21 -0
- data/spec/spec_tests/data/crud/read/count-collation.yml +25 -0
- data/spec/spec_tests/data/crud/read/count-empty.yml +29 -0
- data/spec/spec_tests/data/crud/read/count.yml +74 -0
- data/spec/spec_tests/data/crud/read/distinct-collation.yml +17 -0
- data/spec/spec_tests/data/crud/read/distinct.yml +32 -0
- data/spec/spec_tests/data/crud/read/find-collation.yml +15 -0
- data/spec/spec_tests/data/crud/read/find.yml +49 -0
- data/spec/spec_tests/data/crud/write/bulkWrite-arrayFilters.yml +45 -0
- data/spec/spec_tests/data/crud/write/bulkWrite-collation.yml +101 -0
- data/spec/spec_tests/data/crud/write/bulkWrite.yml +405 -0
- data/spec/spec_tests/data/crud/write/deleteMany-collation.yml +22 -0
- data/spec/spec_tests/data/crud/write/deleteMany.yml +35 -0
- data/spec/spec_tests/data/crud/write/deleteOne-collation.yml +22 -0
- data/spec/spec_tests/data/crud/write/deleteOne.yml +48 -0
- data/spec/spec_tests/data/crud/write/findOneAndDelete-collation.yml +23 -0
- data/spec/spec_tests/data/crud/write/findOneAndDelete.yml +53 -0
- data/spec/spec_tests/data/crud/write/findOneAndReplace-collation.yml +24 -0
- data/spec/spec_tests/data/crud/write/findOneAndReplace-upsert.yml +91 -0
- data/spec/spec_tests/data/crud/write/findOneAndReplace-upsert_pre_2.6.yml +88 -0
- data/spec/spec_tests/data/crud/write/findOneAndReplace.yml +113 -0
- data/spec/spec_tests/data/crud/write/findOneAndUpdate-arrayFilters.yml +69 -0
- data/spec/spec_tests/data/crud/write/findOneAndUpdate-collation.yml +27 -0
- data/spec/spec_tests/data/crud/write/findOneAndUpdate.yml +163 -0
- data/spec/spec_tests/data/crud/write/insertMany.yml +81 -0
- data/spec/spec_tests/data/crud/write/insertOne.yml +18 -0
- data/spec/spec_tests/data/crud/write/replaceOne-collation.yml +24 -0
- data/spec/spec_tests/data/crud/write/replaceOne-pre_2.6.yml +98 -0
- data/spec/spec_tests/data/crud/write/replaceOne-upsert.yml +48 -0
- data/spec/spec_tests/data/crud/write/replaceOne.yml +102 -0
- data/spec/spec_tests/data/crud/write/updateMany-arrayFilters.yml +66 -0
- data/spec/spec_tests/data/crud/write/updateMany-collation.yml +28 -0
- data/spec/spec_tests/data/crud/write/updateMany-pre_2.6.yml +86 -0
- data/spec/spec_tests/data/crud/write/updateMany.yml +87 -0
- data/spec/spec_tests/data/crud/write/updateOne-arrayFilters.yml +114 -0
- data/spec/spec_tests/data/crud/write/updateOne-collation.yml +25 -0
- data/spec/spec_tests/data/crud/write/updateOne-pre_2.6.yml +83 -0
- data/spec/spec_tests/data/crud/write/updateOne.yml +84 -0
- data/spec/spec_tests/data/crud_unified/estimatedDocumentCount.yml +267 -0
- data/spec/spec_tests/data/crud_unified/updateWithPipelines.yml +305 -0
- data/spec/spec_tests/data/crud_v2/aggregate-merge.yml +103 -0
- data/spec/spec_tests/data/crud_v2/aggregate-out-readConcern.yml +111 -0
- data/spec/spec_tests/data/crud_v2/bulkWrite-arrayFilters.yml +103 -0
- data/spec/spec_tests/data/crud_v2/bulkWrite-delete-hint-clientError.yml +63 -0
- data/spec/spec_tests/data/crud_v2/bulkWrite-delete-hint-serverError.yml +92 -0
- data/spec/spec_tests/data/crud_v2/bulkWrite-delete-hint.yml +103 -0
- data/spec/spec_tests/data/crud_v2/bulkWrite-update-hint-clientError.yml +90 -0
- data/spec/spec_tests/data/crud_v2/bulkWrite-update-hint-serverError.yml +147 -0
- data/spec/spec_tests/data/crud_v2/bulkWrite-update-hint.yml +164 -0
- data/spec/spec_tests/data/crud_v2/db-aggregate.yml +39 -0
- data/spec/spec_tests/data/crud_v2/deleteMany-hint-clientError.yml +43 -0
- data/spec/spec_tests/data/crud_v2/deleteMany-hint-serverError.yml +62 -0
- data/spec/spec_tests/data/crud_v2/deleteMany-hint.yml +58 -0
- data/spec/spec_tests/data/crud_v2/deleteOne-hint-clientError.yml +41 -0
- data/spec/spec_tests/data/crud_v2/deleteOne-hint-serverError.yml +60 -0
- data/spec/spec_tests/data/crud_v2/deleteOne-hint.yml +57 -0
- data/spec/spec_tests/data/crud_v2/find-allowdiskuse-clientError.yml +28 -0
- data/spec/spec_tests/data/crud_v2/find-allowdiskuse-serverError.yml +44 -0
- data/spec/spec_tests/data/crud_v2/find-allowdiskuse.yml +50 -0
- data/spec/spec_tests/data/crud_v2/findOneAndDelete-hint-clientError.yml +45 -0
- data/spec/spec_tests/data/crud_v2/findOneAndDelete-hint-serverError.yml +60 -0
- data/spec/spec_tests/data/crud_v2/findOneAndDelete-hint.yml +56 -0
- data/spec/spec_tests/data/crud_v2/findOneAndReplace-hint-clientError.yml +40 -0
- data/spec/spec_tests/data/crud_v2/findOneAndReplace-hint-serverError.yml +59 -0
- data/spec/spec_tests/data/crud_v2/findOneAndReplace-hint.yml +55 -0
- data/spec/spec_tests/data/crud_v2/findOneAndUpdate-hint-clientError.yml +40 -0
- data/spec/spec_tests/data/crud_v2/findOneAndUpdate-hint-serverError.yml +58 -0
- data/spec/spec_tests/data/crud_v2/findOneAndUpdate-hint.yml +55 -0
- data/spec/spec_tests/data/crud_v2/replaceOne-hint.yml +61 -0
- data/spec/spec_tests/data/crud_v2/unacknowledged-bulkWrite-delete-hint-clientError.yml +60 -0
- data/spec/spec_tests/data/crud_v2/unacknowledged-bulkWrite-update-hint-clientError.yml +88 -0
- data/spec/spec_tests/data/crud_v2/unacknowledged-deleteMany-hint-clientError.yml +40 -0
- data/spec/spec_tests/data/crud_v2/unacknowledged-deleteOne-hint-clientError.yml +38 -0
- data/spec/spec_tests/data/crud_v2/unacknowledged-findOneAndDelete-hint-clientError.yml +42 -0
- data/spec/spec_tests/data/crud_v2/unacknowledged-findOneAndReplace-hint-clientError.yml +40 -0
- data/spec/spec_tests/data/crud_v2/unacknowledged-findOneAndUpdate-hint-clientError.yml +40 -0
- data/spec/spec_tests/data/crud_v2/unacknowledged-replaceOne-hint-clientError.yml +40 -0
- data/spec/spec_tests/data/crud_v2/unacknowledged-updateMany-hint-clientError.yml +43 -0
- data/spec/spec_tests/data/crud_v2/unacknowledged-updateOne-hint-clientError.yml +40 -0
- data/spec/spec_tests/data/crud_v2/updateMany-hint-clientError.yml +45 -0
- data/spec/spec_tests/data/crud_v2/updateMany-hint-serverError.yml +66 -0
- data/spec/spec_tests/data/crud_v2/updateMany-hint.yml +65 -0
- data/spec/spec_tests/data/crud_v2/updateOne-hint-clientError.yml +43 -0
- data/spec/spec_tests/data/crud_v2/updateOne-hint-serverError.yml +62 -0
- data/spec/spec_tests/data/crud_v2/updateOne-hint.yml +61 -0
- data/spec/spec_tests/data/crud_v2/updateWithPipelines.yml +157 -0
- data/spec/spec_tests/data/dns_seedlist_discovery/direct-connection-false.yml +10 -0
- data/spec/spec_tests/data/dns_seedlist_discovery/direct-connection-true.yml +5 -0
- data/spec/spec_tests/data/dns_seedlist_discovery/longer-parent-in-return.yml +11 -0
- data/spec/spec_tests/data/dns_seedlist_discovery/misformatted-option.yml +5 -0
- data/spec/spec_tests/data/dns_seedlist_discovery/no-results.yml +5 -0
- data/spec/spec_tests/data/dns_seedlist_discovery/not-enough-parts.yml +5 -0
- data/spec/spec_tests/data/dns_seedlist_discovery/one-result-default-port.yml +10 -0
- data/spec/spec_tests/data/dns_seedlist_discovery/one-txt-record-multiple-strings.yml +10 -0
- data/spec/spec_tests/data/dns_seedlist_discovery/one-txt-record.yml +11 -0
- data/spec/spec_tests/data/dns_seedlist_discovery/parent-part-mismatch1.yml +5 -0
- data/spec/spec_tests/data/dns_seedlist_discovery/parent-part-mismatch2.yml +5 -0
- data/spec/spec_tests/data/dns_seedlist_discovery/parent-part-mismatch3.yml +5 -0
- data/spec/spec_tests/data/dns_seedlist_discovery/parent-part-mismatch4.yml +5 -0
- data/spec/spec_tests/data/dns_seedlist_discovery/parent-part-mismatch5.yml +5 -0
- data/spec/spec_tests/data/dns_seedlist_discovery/returned-parent-too-short.yml +5 -0
- data/spec/spec_tests/data/dns_seedlist_discovery/returned-parent-wrong.yml +5 -0
- data/spec/spec_tests/data/dns_seedlist_discovery/two-results-default-port.yml +11 -0
- data/spec/spec_tests/data/dns_seedlist_discovery/two-results-nonstandard-port.yml +11 -0
- data/spec/spec_tests/data/dns_seedlist_discovery/two-txt-records.yml +5 -0
- data/spec/spec_tests/data/dns_seedlist_discovery/txt-record-not-allowed-option.yml +5 -0
- data/spec/spec_tests/data/dns_seedlist_discovery/txt-record-with-overridden-ssl-option.yml +11 -0
- data/spec/spec_tests/data/dns_seedlist_discovery/txt-record-with-overridden-uri-option.yml +11 -0
- data/spec/spec_tests/data/dns_seedlist_discovery/txt-record-with-unallowed-option.yml +5 -0
- data/spec/spec_tests/data/dns_seedlist_discovery/uri-with-port.yml +5 -0
- data/spec/spec_tests/data/dns_seedlist_discovery/uri-with-two-hosts.yml +5 -0
- data/spec/spec_tests/data/gridfs/delete.yml +123 -0
- data/spec/spec_tests/data/gridfs/download.yml +192 -0
- data/spec/spec_tests/data/gridfs/download_by_name.yml +113 -0
- data/spec/spec_tests/data/gridfs/upload.yml +158 -0
- data/spec/spec_tests/data/max_staleness/ReplicaSetNoPrimary/DefaultNoMaxStaleness.yml +26 -0
- data/spec/spec_tests/data/max_staleness/ReplicaSetNoPrimary/Incompatible.yml +25 -0
- data/spec/spec_tests/data/max_staleness/ReplicaSetNoPrimary/LastUpdateTime.yml +33 -0
- data/spec/spec_tests/data/max_staleness/ReplicaSetNoPrimary/MaxStalenessTooSmall.yml +15 -0
- data/spec/spec_tests/data/max_staleness/ReplicaSetNoPrimary/Nearest.yml +33 -0
- data/spec/spec_tests/data/max_staleness/ReplicaSetNoPrimary/Nearest2.yml +33 -0
- data/spec/spec_tests/data/max_staleness/ReplicaSetNoPrimary/NoKnownServers.yml +16 -0
- data/spec/spec_tests/data/max_staleness/ReplicaSetNoPrimary/PrimaryPreferred.yml +27 -0
- data/spec/spec_tests/data/max_staleness/ReplicaSetNoPrimary/PrimaryPreferred_tags.yml +36 -0
- data/spec/spec_tests/data/max_staleness/ReplicaSetNoPrimary/Secondary.yml +51 -0
- data/spec/spec_tests/data/max_staleness/ReplicaSetNoPrimary/SecondaryPreferred.yml +26 -0
- data/spec/spec_tests/data/max_staleness/ReplicaSetNoPrimary/SecondaryPreferred_tags.yml +51 -0
- data/spec/spec_tests/data/max_staleness/ReplicaSetNoPrimary/ZeroMaxStaleness.yml +23 -0
- data/spec/spec_tests/data/max_staleness/ReplicaSetWithPrimary/DefaultNoMaxStaleness.yml +26 -0
- data/spec/spec_tests/data/max_staleness/ReplicaSetWithPrimary/Incompatible.yml +25 -0
- data/spec/spec_tests/data/max_staleness/ReplicaSetWithPrimary/LastUpdateTime.yml +35 -0
- data/spec/spec_tests/data/max_staleness/ReplicaSetWithPrimary/LongHeartbeat.yml +29 -0
- data/spec/spec_tests/data/max_staleness/ReplicaSetWithPrimary/LongHeartbeat2.yml +25 -0
- data/spec/spec_tests/data/max_staleness/ReplicaSetWithPrimary/MaxStalenessTooSmall.yml +26 -0
- data/spec/spec_tests/data/max_staleness/ReplicaSetWithPrimary/MaxStalenessWithModePrimary.yml +23 -0
- data/spec/spec_tests/data/max_staleness/ReplicaSetWithPrimary/Nearest.yml +33 -0
- data/spec/spec_tests/data/max_staleness/ReplicaSetWithPrimary/Nearest2.yml +33 -0
- data/spec/spec_tests/data/max_staleness/ReplicaSetWithPrimary/Nearest_tags.yml +36 -0
- data/spec/spec_tests/data/max_staleness/ReplicaSetWithPrimary/PrimaryPreferred.yml +27 -0
- data/spec/spec_tests/data/max_staleness/ReplicaSetWithPrimary/PrimaryPreferred_incompatible.yml +27 -0
- data/spec/spec_tests/data/max_staleness/ReplicaSetWithPrimary/SecondaryPreferred.yml +26 -0
- data/spec/spec_tests/data/max_staleness/ReplicaSetWithPrimary/SecondaryPreferred_tags.yml +59 -0
- data/spec/spec_tests/data/max_staleness/ReplicaSetWithPrimary/SecondaryPreferred_tags2.yml +43 -0
- data/spec/spec_tests/data/max_staleness/ReplicaSetWithPrimary/Secondary_tags.yml +59 -0
- data/spec/spec_tests/data/max_staleness/ReplicaSetWithPrimary/Secondary_tags2.yml +43 -0
- data/spec/spec_tests/data/max_staleness/ReplicaSetWithPrimary/ZeroMaxStaleness.yml +23 -0
- data/spec/spec_tests/data/max_staleness/Sharded/Incompatible.yml +25 -0
- data/spec/spec_tests/data/max_staleness/Sharded/SmallMaxStaleness.yml +28 -0
- data/spec/spec_tests/data/max_staleness/Single/Incompatible.yml +18 -0
- data/spec/spec_tests/data/max_staleness/Single/SmallMaxStaleness.yml +20 -0
- data/spec/spec_tests/data/max_staleness/Unknown/SmallMaxStaleness.yml +15 -0
- data/spec/spec_tests/data/read_write_concern/connection-string/read-concern.yml +32 -0
- data/spec/spec_tests/data/read_write_concern/connection-string/write-concern.yml +79 -0
- data/spec/spec_tests/data/read_write_concern/document/read-concern.yml +37 -0
- data/spec/spec_tests/data/read_write_concern/document/write-concern.yml +100 -0
- data/spec/spec_tests/data/read_write_concern/operation/default-write-concern-2.6.yml +215 -0
- data/spec/spec_tests/data/read_write_concern/operation/default-write-concern-3.2.yml +58 -0
- data/spec/spec_tests/data/read_write_concern/operation/default-write-concern-3.4.yml +95 -0
- data/spec/spec_tests/data/read_write_concern/operation/default-write-concern-4.2.yml +36 -0
- data/spec/spec_tests/data/retryable_reads/aggregate-merge.yml +39 -0
- data/spec/spec_tests/data/retryable_reads/aggregate-serverErrors.yml +157 -0
- data/spec/spec_tests/data/retryable_reads/aggregate.yml +87 -0
- data/spec/spec_tests/data/retryable_reads/changeStreams-client.watch-serverErrors.yml +150 -0
- data/spec/spec_tests/data/retryable_reads/changeStreams-client.watch.yml +62 -0
- data/spec/spec_tests/data/retryable_reads/changeStreams-db.coll.watch-serverErrors.yml +150 -0
- data/spec/spec_tests/data/retryable_reads/changeStreams-db.coll.watch.yml +66 -0
- data/spec/spec_tests/data/retryable_reads/changeStreams-db.watch-serverErrors.yml +154 -0
- data/spec/spec_tests/data/retryable_reads/changeStreams-db.watch.yml +62 -0
- data/spec/spec_tests/data/retryable_reads/count-serverErrors.yml +150 -0
- data/spec/spec_tests/data/retryable_reads/count.yml +64 -0
- data/spec/spec_tests/data/retryable_reads/countDocuments-serverErrors.yml +150 -0
- data/spec/spec_tests/data/retryable_reads/countDocuments.yml +64 -0
- data/spec/spec_tests/data/retryable_reads/distinct-serverErrors.yml +156 -0
- data/spec/spec_tests/data/retryable_reads/distinct.yml +71 -0
- data/spec/spec_tests/data/retryable_reads/estimatedDocumentCount-4.9.yml +60 -0
- data/spec/spec_tests/data/retryable_reads/estimatedDocumentCount-pre4.9.yml +64 -0
- data/spec/spec_tests/data/retryable_reads/estimatedDocumentCount-serverErrors-4.9.yml +146 -0
- data/spec/spec_tests/data/retryable_reads/estimatedDocumentCount-serverErrors-pre4.9.yml +150 -0
- data/spec/spec_tests/data/retryable_reads/find-serverErrors.yml +160 -0
- data/spec/spec_tests/data/retryable_reads/find.yml +86 -0
- data/spec/spec_tests/data/retryable_reads/findOne-serverErrors.yml +154 -0
- data/spec/spec_tests/data/retryable_reads/findOne.yml +68 -0
- data/spec/spec_tests/data/retryable_reads/gridfs-download-serverErrors.yml +173 -0
- data/spec/spec_tests/data/retryable_reads/gridfs-download.yml +79 -0
- data/spec/spec_tests/data/retryable_reads/gridfs-downloadByName-serverErrors.yml +174 -0
- data/spec/spec_tests/data/retryable_reads/gridfs-downloadByName.yml +79 -0
- data/spec/spec_tests/data/retryable_reads/listCollectionNames-serverErrors.yml +143 -0
- data/spec/spec_tests/data/retryable_reads/listCollectionNames.yml +59 -0
- data/spec/spec_tests/data/retryable_reads/listCollectionObjects-serverErrors.yml +144 -0
- data/spec/spec_tests/data/retryable_reads/listCollectionObjects.yml +59 -0
- data/spec/spec_tests/data/retryable_reads/listCollections-serverErrors.yml +143 -0
- data/spec/spec_tests/data/retryable_reads/listCollections.yml +59 -0
- data/spec/spec_tests/data/retryable_reads/listDatabaseNames-serverErrors.yml +143 -0
- data/spec/spec_tests/data/retryable_reads/listDatabaseNames.yml +59 -0
- data/spec/spec_tests/data/retryable_reads/listDatabaseObjects-serverErrors.yml +144 -0
- data/spec/spec_tests/data/retryable_reads/listDatabaseObjects.yml +59 -0
- data/spec/spec_tests/data/retryable_reads/listDatabases-serverErrors.yml +144 -0
- data/spec/spec_tests/data/retryable_reads/listDatabases.yml +59 -0
- data/spec/spec_tests/data/retryable_reads/listIndexNames-serverErrors.yml +144 -0
- data/spec/spec_tests/data/retryable_reads/listIndexNames.yml +60 -0
- data/spec/spec_tests/data/retryable_reads/listIndexes-serverErrors.yml +145 -0
- data/spec/spec_tests/data/retryable_reads/listIndexes.yml +60 -0
- data/spec/spec_tests/data/retryable_reads/mapReduce.yml +60 -0
- data/spec/spec_tests/data/retryable_writes/bulkWrite-errorLabels.yml +77 -0
- data/spec/spec_tests/data/retryable_writes/bulkWrite-serverErrors.yml +130 -0
- data/spec/spec_tests/data/retryable_writes/bulkWrite.yml +402 -0
- data/spec/spec_tests/data/retryable_writes/deleteMany.yml +22 -0
- data/spec/spec_tests/data/retryable_writes/deleteOne-errorLabels.yml +48 -0
- data/spec/spec_tests/data/retryable_writes/deleteOne-serverErrors.yml +73 -0
- data/spec/spec_tests/data/retryable_writes/deleteOne.yml +57 -0
- data/spec/spec_tests/data/retryable_writes/findOneAndDelete-errorLabels.yml +49 -0
- data/spec/spec_tests/data/retryable_writes/findOneAndDelete-serverErrors.yml +74 -0
- data/spec/spec_tests/data/retryable_writes/findOneAndDelete.yml +58 -0
- data/spec/spec_tests/data/retryable_writes/findOneAndReplace-errorLabels.yml +52 -0
- data/spec/spec_tests/data/retryable_writes/findOneAndReplace-serverErrors.yml +80 -0
- data/spec/spec_tests/data/retryable_writes/findOneAndReplace.yml +63 -0
- data/spec/spec_tests/data/retryable_writes/findOneAndUpdate-errorLabels.yml +52 -0
- data/spec/spec_tests/data/retryable_writes/findOneAndUpdate-serverErrors.yml +79 -0
- data/spec/spec_tests/data/retryable_writes/findOneAndUpdate.yml +62 -0
- data/spec/spec_tests/data/retryable_writes/insertMany-errorLabels.yml +54 -0
- data/spec/spec_tests/data/retryable_writes/insertMany-serverErrors.yml +84 -0
- data/spec/spec_tests/data/retryable_writes/insertMany.yml +74 -0
- data/spec/spec_tests/data/retryable_writes/insertOne-errorLabels.yml +44 -0
- data/spec/spec_tests/data/retryable_writes/insertOne-serverErrors.yml +527 -0
- data/spec/spec_tests/data/retryable_writes/insertOne.yml +61 -0
- data/spec/spec_tests/data/retryable_writes/replaceOne-errorLabels.yml +53 -0
- data/spec/spec_tests/data/retryable_writes/replaceOne-serverErrors.yml +82 -0
- data/spec/spec_tests/data/retryable_writes/replaceOne.yml +66 -0
- data/spec/spec_tests/data/retryable_writes/updateMany.yml +27 -0
- data/spec/spec_tests/data/retryable_writes/updateOne-errorLabels.yml +53 -0
- data/spec/spec_tests/data/retryable_writes/updateOne-serverErrors.yml +82 -0
- data/spec/spec_tests/data/retryable_writes/updateOne.yml +129 -0
- data/spec/spec_tests/data/sdam/errors/error_handling_handshake.yml +55 -0
- data/spec/spec_tests/data/sdam/errors/non-stale-network-error.yml +47 -0
- data/spec/spec_tests/data/sdam/errors/non-stale-network-timeout-error.yml +38 -0
- data/spec/spec_tests/data/sdam/errors/non-stale-topologyVersion-greater-InterruptedAtShutdown.yml +61 -0
- data/spec/spec_tests/data/sdam/errors/non-stale-topologyVersion-greater-InterruptedDueToReplStateChange.yml +61 -0
- data/spec/spec_tests/data/sdam/errors/non-stale-topologyVersion-greater-LegacyNotPrimary.yml +61 -0
- data/spec/spec_tests/data/sdam/errors/non-stale-topologyVersion-greater-NotPrimaryNoSecondaryOk.yml +61 -0
- data/spec/spec_tests/data/sdam/errors/non-stale-topologyVersion-greater-NotPrimaryOrSecondary.yml +61 -0
- data/spec/spec_tests/data/sdam/errors/non-stale-topologyVersion-greater-NotWritablePrimary.yml +61 -0
- data/spec/spec_tests/data/sdam/errors/non-stale-topologyVersion-greater-PrimarySteppedDown.yml +61 -0
- data/spec/spec_tests/data/sdam/errors/non-stale-topologyVersion-greater-ShutdownInProgress.yml +61 -0
- data/spec/spec_tests/data/sdam/errors/non-stale-topologyVersion-missing-InterruptedAtShutdown.yml +52 -0
- data/spec/spec_tests/data/sdam/errors/non-stale-topologyVersion-missing-InterruptedDueToReplStateChange.yml +52 -0
- data/spec/spec_tests/data/sdam/errors/non-stale-topologyVersion-missing-LegacyNotPrimary.yml +52 -0
- data/spec/spec_tests/data/sdam/errors/non-stale-topologyVersion-missing-NotPrimaryNoSecondaryOk.yml +52 -0
- data/spec/spec_tests/data/sdam/errors/non-stale-topologyVersion-missing-NotPrimaryOrSecondary.yml +52 -0
- data/spec/spec_tests/data/sdam/errors/non-stale-topologyVersion-missing-NotWritablePrimary.yml +52 -0
- data/spec/spec_tests/data/sdam/errors/non-stale-topologyVersion-missing-PrimarySteppedDown.yml +52 -0
- data/spec/spec_tests/data/sdam/errors/non-stale-topologyVersion-missing-ShutdownInProgress.yml +52 -0
- data/spec/spec_tests/data/sdam/errors/non-stale-topologyVersion-proccessId-changed-InterruptedAtShutdown.yml +61 -0
- data/spec/spec_tests/data/sdam/errors/non-stale-topologyVersion-proccessId-changed-InterruptedDueToReplStateChange.yml +61 -0
- data/spec/spec_tests/data/sdam/errors/non-stale-topologyVersion-proccessId-changed-LegacyNotPrimary.yml +61 -0
- data/spec/spec_tests/data/sdam/errors/non-stale-topologyVersion-proccessId-changed-NotPrimaryNoSecondaryOk.yml +61 -0
- data/spec/spec_tests/data/sdam/errors/non-stale-topologyVersion-proccessId-changed-NotPrimaryOrSecondary.yml +61 -0
- data/spec/spec_tests/data/sdam/errors/non-stale-topologyVersion-proccessId-changed-NotWritablePrimary.yml +61 -0
- data/spec/spec_tests/data/sdam/errors/non-stale-topologyVersion-proccessId-changed-PrimarySteppedDown.yml +61 -0
- data/spec/spec_tests/data/sdam/errors/non-stale-topologyVersion-proccessId-changed-ShutdownInProgress.yml +61 -0
- data/spec/spec_tests/data/sdam/errors/post-42-InterruptedAtShutdown.yml +47 -0
- data/spec/spec_tests/data/sdam/errors/post-42-InterruptedDueToReplStateChange.yml +47 -0
- data/spec/spec_tests/data/sdam/errors/post-42-LegacyNotPrimary.yml +47 -0
- data/spec/spec_tests/data/sdam/errors/post-42-NotPrimaryNoSecondaryOk.yml +47 -0
- data/spec/spec_tests/data/sdam/errors/post-42-NotPrimaryOrSecondary.yml +47 -0
- data/spec/spec_tests/data/sdam/errors/post-42-NotWritablePrimary.yml +47 -0
- data/spec/spec_tests/data/sdam/errors/post-42-PrimarySteppedDown.yml +47 -0
- data/spec/spec_tests/data/sdam/errors/post-42-ShutdownInProgress.yml +47 -0
- data/spec/spec_tests/data/sdam/errors/pre-42-InterruptedAtShutdown.yml +47 -0
- data/spec/spec_tests/data/sdam/errors/pre-42-InterruptedDueToReplStateChange.yml +47 -0
- data/spec/spec_tests/data/sdam/errors/pre-42-LegacyNotPrimary.yml +47 -0
- data/spec/spec_tests/data/sdam/errors/pre-42-NotPrimaryNoSecondaryOk.yml +47 -0
- data/spec/spec_tests/data/sdam/errors/pre-42-NotPrimaryOrSecondary.yml +47 -0
- data/spec/spec_tests/data/sdam/errors/pre-42-NotWritablePrimary.yml +47 -0
- data/spec/spec_tests/data/sdam/errors/pre-42-PrimarySteppedDown.yml +47 -0
- data/spec/spec_tests/data/sdam/errors/pre-42-ShutdownInProgress.yml +47 -0
- data/spec/spec_tests/data/sdam/errors/prefer-error-code.yml +54 -0
- data/spec/spec_tests/data/sdam/errors/stale-generation-InterruptedAtShutdown.yml +91 -0
- data/spec/spec_tests/data/sdam/errors/stale-generation-InterruptedDueToReplStateChange.yml +91 -0
- data/spec/spec_tests/data/sdam/errors/stale-generation-NotPrimaryNoSecondaryOk.yml +91 -0
- data/spec/spec_tests/data/sdam/errors/stale-generation-NotPrimaryOrSecondary.yml +91 -0
- data/spec/spec_tests/data/sdam/errors/stale-generation-NotWritablePrimary.yml +91 -0
- data/spec/spec_tests/data/sdam/errors/stale-generation-PrimarySteppedDown.yml +91 -0
- data/spec/spec_tests/data/sdam/errors/stale-generation-ShutdownInProgress.yml +91 -0
- data/spec/spec_tests/data/sdam/errors/stale-generation-afterHandshakeCompletes-InterruptedAtShutdown.yml +91 -0
- data/spec/spec_tests/data/sdam/errors/stale-generation-afterHandshakeCompletes-InterruptedDueToReplStateChange.yml +91 -0
- data/spec/spec_tests/data/sdam/errors/stale-generation-afterHandshakeCompletes-LegacyNotPrimary.yml +91 -0
- data/spec/spec_tests/data/sdam/errors/stale-generation-afterHandshakeCompletes-NotPrimaryNoSecondaryOk.yml +91 -0
- data/spec/spec_tests/data/sdam/errors/stale-generation-afterHandshakeCompletes-NotPrimaryOrSecondary.yml +91 -0
- data/spec/spec_tests/data/sdam/errors/stale-generation-afterHandshakeCompletes-NotWritablePrimary.yml +91 -0
- data/spec/spec_tests/data/sdam/errors/stale-generation-afterHandshakeCompletes-PrimarySteppedDown.yml +91 -0
- data/spec/spec_tests/data/sdam/errors/stale-generation-afterHandshakeCompletes-ShutdownInProgress.yml +91 -0
- data/spec/spec_tests/data/sdam/errors/stale-generation-afterHandshakeCompletes-network.yml +82 -0
- data/spec/spec_tests/data/sdam/errors/stale-generation-afterHandshakeCompletes-timeout.yml +82 -0
- data/spec/spec_tests/data/sdam/errors/stale-generation-beforeHandshakeCompletes-InterruptedAtShutdown.yml +91 -0
- data/spec/spec_tests/data/sdam/errors/stale-generation-beforeHandshakeCompletes-InterruptedDueToReplStateChange.yml +91 -0
- data/spec/spec_tests/data/sdam/errors/stale-generation-beforeHandshakeCompletes-LegacyNotPrimary.yml +91 -0
- data/spec/spec_tests/data/sdam/errors/stale-generation-beforeHandshakeCompletes-NotPrimaryNoSecondaryOk.yml +91 -0
- data/spec/spec_tests/data/sdam/errors/stale-generation-beforeHandshakeCompletes-NotPrimaryOrSecondary.yml +91 -0
- data/spec/spec_tests/data/sdam/errors/stale-generation-beforeHandshakeCompletes-NotWritablePrimary.yml +91 -0
- data/spec/spec_tests/data/sdam/errors/stale-generation-beforeHandshakeCompletes-PrimarySteppedDown.yml +91 -0
- data/spec/spec_tests/data/sdam/errors/stale-generation-beforeHandshakeCompletes-ShutdownInProgress.yml +91 -0
- data/spec/spec_tests/data/sdam/errors/stale-generation-beforeHandshakeCompletes-network.yml +82 -0
- data/spec/spec_tests/data/sdam/errors/stale-generation-beforeHandshakeCompletes-timeout.yml +82 -0
- data/spec/spec_tests/data/sdam/errors/stale-topologyVersion-InterruptedAtShutdown.yml +65 -0
- data/spec/spec_tests/data/sdam/errors/stale-topologyVersion-InterruptedDueToReplStateChange.yml +65 -0
- data/spec/spec_tests/data/sdam/errors/stale-topologyVersion-LegacyNotPrimary.yml +65 -0
- data/spec/spec_tests/data/sdam/errors/stale-topologyVersion-NotPrimaryNoSecondaryOk.yml +65 -0
- data/spec/spec_tests/data/sdam/errors/stale-topologyVersion-NotPrimaryOrSecondary.yml +65 -0
- data/spec/spec_tests/data/sdam/errors/stale-topologyVersion-NotWritablePrimary.yml +65 -0
- data/spec/spec_tests/data/sdam/errors/stale-topologyVersion-PrimarySteppedDown.yml +65 -0
- data/spec/spec_tests/data/sdam/errors/stale-topologyVersion-ShutdownInProgress.yml +65 -0
- data/spec/spec_tests/data/sdam/errors/write_errors_ignored.yml +42 -0
- data/spec/spec_tests/data/sdam/rs/compatible.yml +45 -0
- data/spec/spec_tests/data/sdam/rs/compatible_unknown.yml +34 -0
- data/spec/spec_tests/data/sdam/rs/discover_arbiters.yml +44 -0
- data/spec/spec_tests/data/sdam/rs/discover_arbiters_replicaset.yml +44 -0
- data/spec/spec_tests/data/sdam/rs/discover_ghost.yml +36 -0
- data/spec/spec_tests/data/sdam/rs/discover_ghost_replicaset.yml +42 -0
- data/spec/spec_tests/data/sdam/rs/discover_hidden.yml +51 -0
- data/spec/spec_tests/data/sdam/rs/discover_hidden_replicaset.yml +51 -0
- data/spec/spec_tests/data/sdam/rs/discover_passives.yml +83 -0
- data/spec/spec_tests/data/sdam/rs/discover_passives_replicaset.yml +83 -0
- data/spec/spec_tests/data/sdam/rs/discover_primary.yml +43 -0
- data/spec/spec_tests/data/sdam/rs/discover_primary_replicaset.yml +43 -0
- data/spec/spec_tests/data/sdam/rs/discover_rsother.yml +50 -0
- data/spec/spec_tests/data/sdam/rs/discover_rsother_replicaset.yml +68 -0
- data/spec/spec_tests/data/sdam/rs/discover_secondary.yml +44 -0
- data/spec/spec_tests/data/sdam/rs/discover_secondary_replicaset.yml +44 -0
- data/spec/spec_tests/data/sdam/rs/discovery.yml +207 -0
- data/spec/spec_tests/data/sdam/rs/equal_electionids.yml +57 -0
- data/spec/spec_tests/data/sdam/rs/hosts_differ_from_seeds.yml +37 -0
- data/spec/spec_tests/data/sdam/rs/incompatible_arbiter.yml +36 -0
- data/spec/spec_tests/data/sdam/rs/incompatible_ghost.yml +34 -0
- data/spec/spec_tests/data/sdam/rs/incompatible_other.yml +36 -0
- data/spec/spec_tests/data/sdam/rs/ls_timeout.yml +249 -0
- data/spec/spec_tests/data/sdam/rs/member_reconfig.yml +74 -0
- data/spec/spec_tests/data/sdam/rs/member_standalone.yml +66 -0
- data/spec/spec_tests/data/sdam/rs/new_primary.yml +80 -0
- data/spec/spec_tests/data/sdam/rs/new_primary_new_electionid.yml +119 -0
- data/spec/spec_tests/data/sdam/rs/new_primary_new_setversion.yml +119 -0
- data/spec/spec_tests/data/sdam/rs/new_primary_wrong_set_name.yml +77 -0
- data/spec/spec_tests/data/sdam/rs/non_rs_member.yml +33 -0
- data/spec/spec_tests/data/sdam/rs/normalize_case.yml +52 -0
- data/spec/spec_tests/data/sdam/rs/normalize_case_me.yml +102 -0
- data/spec/spec_tests/data/sdam/rs/null_election_id.yml +175 -0
- data/spec/spec_tests/data/sdam/rs/primary_becomes_ghost.yml +65 -0
- data/spec/spec_tests/data/sdam/rs/primary_becomes_mongos.yml +58 -0
- data/spec/spec_tests/data/sdam/rs/primary_becomes_standalone.yml +55 -0
- data/spec/spec_tests/data/sdam/rs/primary_changes_set_name.yml +63 -0
- data/spec/spec_tests/data/sdam/rs/primary_disconnect.yml +59 -0
- data/spec/spec_tests/data/sdam/rs/primary_disconnect_electionid.yml +189 -0
- data/spec/spec_tests/data/sdam/rs/primary_disconnect_setversion.yml +189 -0
- data/spec/spec_tests/data/sdam/rs/primary_hint_from_secondary_with_mismatched_me.yml +64 -0
- data/spec/spec_tests/data/sdam/rs/primary_mismatched_me.yml +27 -0
- data/spec/spec_tests/data/sdam/rs/primary_mismatched_me_not_removed.yml +75 -0
- data/spec/spec_tests/data/sdam/rs/primary_reports_new_member.yml +175 -0
- data/spec/spec_tests/data/sdam/rs/primary_to_no_primary_mismatched_me.yml +81 -0
- data/spec/spec_tests/data/sdam/rs/primary_wrong_set_name.yml +30 -0
- data/spec/spec_tests/data/sdam/rs/repeated.yml +105 -0
- data/spec/spec_tests/data/sdam/rs/replicaset_rsnp.yml +21 -0
- data/spec/spec_tests/data/sdam/rs/response_from_removed.yml +69 -0
- data/spec/spec_tests/data/sdam/rs/ruby_primary_address_change.yml +31 -0
- data/spec/spec_tests/data/sdam/rs/ruby_secondary_wrong_set_name_with_primary_second.yml +73 -0
- data/spec/spec_tests/data/sdam/rs/sec_not_auth.yml +55 -0
- data/spec/spec_tests/data/sdam/rs/secondary_ignore_ok_0.yml +87 -0
- data/spec/spec_tests/data/sdam/rs/secondary_mismatched_me.yml +28 -0
- data/spec/spec_tests/data/sdam/rs/secondary_wrong_set_name.yml +31 -0
- data/spec/spec_tests/data/sdam/rs/secondary_wrong_set_name_with_primary.yml +75 -0
- data/spec/spec_tests/data/sdam/rs/setversion_without_electionid.yml +79 -0
- data/spec/spec_tests/data/sdam/rs/stepdown_change_set_name.yml +65 -0
- data/spec/spec_tests/data/sdam/rs/too_new.yml +45 -0
- data/spec/spec_tests/data/sdam/rs/too_old.yml +41 -0
- data/spec/spec_tests/data/sdam/rs/topology_version_equal.yml +68 -0
- data/spec/spec_tests/data/sdam/rs/topology_version_greater.yml +194 -0
- data/spec/spec_tests/data/sdam/rs/topology_version_less.yml +64 -0
- data/spec/spec_tests/data/sdam/rs/unexpected_mongos.yml +29 -0
- data/spec/spec_tests/data/sdam/rs/use_setversion_without_electionid.yml +117 -0
- data/spec/spec_tests/data/sdam/rs/wrong_set_name.yml +38 -0
- data/spec/spec_tests/data/sdam/sharded/compatible.yml +40 -0
- data/spec/spec_tests/data/sdam/sharded/discover_single_mongos.yml +24 -0
- data/spec/spec_tests/data/sdam/sharded/ls_timeout_mongos.yml +101 -0
- data/spec/spec_tests/data/sdam/sharded/mongos_disconnect.yml +113 -0
- data/spec/spec_tests/data/sdam/sharded/multiple_mongoses.yml +52 -0
- data/spec/spec_tests/data/sdam/sharded/non_mongos_removed.yml +47 -0
- data/spec/spec_tests/data/sdam/sharded/normalize_uri_case.yml +32 -0
- data/spec/spec_tests/data/sdam/sharded/ruby_primary_different_address.yml +21 -0
- data/spec/spec_tests/data/sdam/sharded/ruby_primary_mismatched_me.yml +22 -0
- data/spec/spec_tests/data/sdam/sharded/too_new.yml +38 -0
- data/spec/spec_tests/data/sdam/sharded/too_old.yml +38 -0
- data/spec/spec_tests/data/sdam/single/compatible.yml +27 -0
- data/spec/spec_tests/data/sdam/single/direct_connection_external_ip.yml +37 -0
- data/spec/spec_tests/data/sdam/single/direct_connection_mongos.yml +36 -0
- data/spec/spec_tests/data/sdam/single/direct_connection_replicaset.yml +23 -0
- data/spec/spec_tests/data/sdam/single/direct_connection_rsarbiter.yml +38 -0
- data/spec/spec_tests/data/sdam/single/direct_connection_rsprimary.yml +37 -0
- data/spec/spec_tests/data/sdam/single/direct_connection_rssecondary.yml +38 -0
- data/spec/spec_tests/data/sdam/single/direct_connection_standalone.yml +35 -0
- data/spec/spec_tests/data/sdam/single/direct_connection_unavailable_seed.yml +28 -0
- data/spec/spec_tests/data/sdam/single/direct_connection_wrong_set_name.yml +40 -0
- data/spec/spec_tests/data/sdam/single/discover_standalone.yml +35 -0
- data/spec/spec_tests/data/sdam/single/discover_unavailable_seed.yml +28 -0
- data/spec/spec_tests/data/sdam/single/ls_timeout_standalone.yml +36 -0
- data/spec/spec_tests/data/sdam/single/not_ok_response.yml +44 -0
- data/spec/spec_tests/data/sdam/single/ruby_primary_different_address.yml +24 -0
- data/spec/spec_tests/data/sdam/single/ruby_primary_mismatched_me.yml +25 -0
- data/spec/spec_tests/data/sdam/single/standalone_removed.yml +35 -0
- data/spec/spec_tests/data/sdam/single/standalone_using_legacy_hello.yml +34 -0
- data/spec/spec_tests/data/sdam/single/too_new.yml +27 -0
- data/spec/spec_tests/data/sdam/single/too_old.yml +25 -0
- data/spec/spec_tests/data/sdam/single/too_old_then_upgraded.yml +48 -0
- data/spec/spec_tests/data/sdam_integration/cancel-server-check.yml +96 -0
- data/spec/spec_tests/data/sdam_integration/connectTimeoutMS.yml +88 -0
- data/spec/spec_tests/data/sdam_integration/find-network-error.yml +83 -0
- data/spec/spec_tests/data/sdam_integration/find-shutdown-error.yml +116 -0
- data/spec/spec_tests/data/sdam_integration/hello-command-error.yml +158 -0
- data/spec/spec_tests/data/sdam_integration/hello-network-error.yml +156 -0
- data/spec/spec_tests/data/sdam_integration/hello-timeout.yml +223 -0
- data/spec/spec_tests/data/sdam_integration/insert-network-error.yml +86 -0
- data/spec/spec_tests/data/sdam_integration/insert-shutdown-error.yml +115 -0
- data/spec/spec_tests/data/sdam_integration/rediscover-quickly-after-step-down.yml +98 -0
- data/spec/spec_tests/data/sdam_monitoring/discovered_standalone.yml +70 -0
- data/spec/spec_tests/data/sdam_monitoring/replica_set_other_chain.yml +222 -0
- data/spec/spec_tests/data/sdam_monitoring/replica_set_other_change.yml +225 -0
- data/spec/spec_tests/data/sdam_monitoring/replica_set_primary_address_change.yml +251 -0
- data/spec/spec_tests/data/sdam_monitoring/replica_set_with_me_mismatch.yml +111 -0
- data/spec/spec_tests/data/sdam_monitoring/replica_set_with_no_primary.yml +113 -0
- data/spec/spec_tests/data/sdam_monitoring/replica_set_with_primary.yml +112 -0
- data/spec/spec_tests/data/sdam_monitoring/replica_set_with_primary_and_secondary.yml +198 -0
- data/spec/spec_tests/data/sdam_monitoring/replica_set_with_primary_removal.yml +175 -0
- data/spec/spec_tests/data/sdam_monitoring/replica_set_with_removal.yml +111 -0
- data/spec/spec_tests/data/sdam_monitoring/replica_set_with_second_seed_removal.yml +106 -0
- data/spec/spec_tests/data/sdam_monitoring/required_replica_set.yml +108 -0
- data/spec/spec_tests/data/sdam_monitoring/standalone.yml +70 -0
- data/spec/spec_tests/data/sdam_monitoring/standalone_repeated.yml +86 -0
- data/spec/spec_tests/data/sdam_monitoring/standalone_suppress_equal_description_changes.yml +73 -0
- data/spec/spec_tests/data/sdam_monitoring/standalone_to_rs_with_me_mismatch.yml +90 -0
- data/spec/spec_tests/data/server_selection/ReplicaSetNoPrimary/read/Nearest.yml +25 -0
- data/spec/spec_tests/data/server_selection/ReplicaSetNoPrimary/read/Nearest_multiple.yml +26 -0
- data/spec/spec_tests/data/server_selection/ReplicaSetNoPrimary/read/Nearest_non_matching.yml +20 -0
- data/spec/spec_tests/data/server_selection/ReplicaSetNoPrimary/read/PossiblePrimary.yml +15 -0
- data/spec/spec_tests/data/server_selection/ReplicaSetNoPrimary/read/PossiblePrimaryNearest.yml +15 -0
- data/spec/spec_tests/data/server_selection/ReplicaSetNoPrimary/read/Primary.yml +18 -0
- data/spec/spec_tests/data/server_selection/ReplicaSetNoPrimary/read/PrimaryPreferred.yml +25 -0
- data/spec/spec_tests/data/server_selection/ReplicaSetNoPrimary/read/PrimaryPreferred_non_matching.yml +20 -0
- data/spec/spec_tests/data/server_selection/ReplicaSetNoPrimary/read/Secondary.yml +25 -0
- data/spec/spec_tests/data/server_selection/ReplicaSetNoPrimary/read/SecondaryPreferred.yml +25 -0
- data/spec/spec_tests/data/server_selection/ReplicaSetNoPrimary/read/SecondaryPreferred_non_matching.yml +20 -0
- data/spec/spec_tests/data/server_selection/ReplicaSetNoPrimary/read/Secondary_multi_tags.yml +31 -0
- data/spec/spec_tests/data/server_selection/ReplicaSetNoPrimary/read/Secondary_multi_tags2.yml +31 -0
- data/spec/spec_tests/data/server_selection/ReplicaSetNoPrimary/read/Secondary_non_matching.yml +20 -0
- data/spec/spec_tests/data/server_selection/ReplicaSetWithPrimary/read/Nearest.yml +32 -0
- data/spec/spec_tests/data/server_selection/ReplicaSetWithPrimary/read/Nearest_multiple.yml +33 -0
- data/spec/spec_tests/data/server_selection/ReplicaSetWithPrimary/read/Nearest_non_matching.yml +25 -0
- data/spec/spec_tests/data/server_selection/ReplicaSetWithPrimary/read/Primary.yml +26 -0
- data/spec/spec_tests/data/server_selection/ReplicaSetWithPrimary/read/PrimaryPreferred.yml +28 -0
- data/spec/spec_tests/data/server_selection/ReplicaSetWithPrimary/read/PrimaryPreferred_non_matching.yml +28 -0
- data/spec/spec_tests/data/server_selection/ReplicaSetWithPrimary/read/Secondary.yml +30 -0
- data/spec/spec_tests/data/server_selection/ReplicaSetWithPrimary/read/SecondaryPreferred.yml +30 -0
- data/spec/spec_tests/data/server_selection/ReplicaSetWithPrimary/read/SecondaryPreferred_non_matching.yml +28 -0
- data/spec/spec_tests/data/server_selection/ReplicaSetWithPrimary/read/SecondaryPreferred_tags.yml +28 -0
- data/spec/spec_tests/data/server_selection/ReplicaSetWithPrimary/read/Secondary_non_matching.yml +25 -0
- data/spec/spec_tests/data/server_selection/Sharded/read/Nearest.yml +21 -0
- data/spec/spec_tests/data/server_selection/Sharded/read/Primary.yml +19 -0
- data/spec/spec_tests/data/server_selection/Sharded/read/PrimaryPreferred.yml +21 -0
- data/spec/spec_tests/data/server_selection/Sharded/read/Secondary.yml +21 -0
- data/spec/spec_tests/data/server_selection/Sharded/read/SecondaryPreferred.yml +21 -0
- data/spec/spec_tests/data/server_selection/Single/read/SecondaryPreferred.yml +18 -0
- data/spec/spec_tests/data/server_selection/Unknown/read/SecondaryPreferred.yml +10 -0
- data/spec/spec_tests/data/server_selection_rtt/first_value.yml +4 -0
- data/spec/spec_tests/data/server_selection_rtt/first_value_zero.yml +4 -0
- data/spec/spec_tests/data/server_selection_rtt/value_test_1.yml +4 -0
- data/spec/spec_tests/data/server_selection_rtt/value_test_2.yml +4 -0
- data/spec/spec_tests/data/server_selection_rtt/value_test_3.yml +4 -0
- data/spec/spec_tests/data/server_selection_rtt/value_test_4.yml +4 -0
- data/spec/spec_tests/data/server_selection_rtt/value_test_5.yml +4 -0
- data/spec/spec_tests/data/transactions/abort.yml +413 -0
- data/spec/spec_tests/data/transactions/bulk.yml +267 -0
- data/spec/spec_tests/data/transactions/causal-consistency.yml +175 -0
- data/spec/spec_tests/data/transactions/commit.yml +603 -0
- data/spec/spec_tests/data/transactions/count.yml +67 -0
- data/spec/spec_tests/data/transactions/create-collection.yml +131 -0
- data/spec/spec_tests/data/transactions/create-index.yml +152 -0
- data/spec/spec_tests/data/transactions/delete.yml +192 -0
- data/spec/spec_tests/data/transactions/error-labels.yml +1030 -0
- data/spec/spec_tests/data/transactions/errors-client.yml +56 -0
- data/spec/spec_tests/data/transactions/errors.yml +133 -0
- data/spec/spec_tests/data/transactions/findOneAndDelete.yml +134 -0
- data/spec/spec_tests/data/transactions/findOneAndReplace.yml +148 -0
- data/spec/spec_tests/data/transactions/findOneAndUpdate.yml +236 -0
- data/spec/spec_tests/data/transactions/insert.yml +390 -0
- data/spec/spec_tests/data/transactions/isolation.yml +133 -0
- data/spec/spec_tests/data/transactions/mongos-pin-auto.yml +1674 -0
- data/spec/spec_tests/data/transactions/mongos-recovery-token.yml +350 -0
- data/spec/spec_tests/data/transactions/pin-mongos.yml +559 -0
- data/spec/spec_tests/data/transactions/read-concern.yml +623 -0
- data/spec/spec_tests/data/transactions/read-pref.yml +348 -0
- data/spec/spec_tests/data/transactions/reads.yml +261 -0
- data/spec/spec_tests/data/transactions/retryable-abort-errorLabels.yml +124 -0
- data/spec/spec_tests/data/transactions/retryable-abort.yml +1315 -0
- data/spec/spec_tests/data/transactions/retryable-commit-errorLabels.yml +132 -0
- data/spec/spec_tests/data/transactions/retryable-commit.yml +1460 -0
- data/spec/spec_tests/data/transactions/retryable-writes.yml +216 -0
- data/spec/spec_tests/data/transactions/run-command.yml +197 -0
- data/spec/spec_tests/data/transactions/transaction-options-repl.yml +117 -0
- data/spec/spec_tests/data/transactions/transaction-options.yml +781 -0
- data/spec/spec_tests/data/transactions/update.yml +246 -0
- data/spec/spec_tests/data/transactions/write-concern.yml +554 -0
- data/spec/spec_tests/data/transactions_api/callback-aborts.yml +170 -0
- data/spec/spec_tests/data/transactions_api/callback-commits.yml +204 -0
- data/spec/spec_tests/data/transactions_api/callback-retry.yml +215 -0
- data/spec/spec_tests/data/transactions_api/commit-retry.yml +324 -0
- data/spec/spec_tests/data/transactions_api/commit-transienttransactionerror-4.2.yml +139 -0
- data/spec/spec_tests/data/transactions_api/commit-transienttransactionerror.yml +175 -0
- data/spec/spec_tests/data/transactions_api/commit-writeconcernerror.yml +216 -0
- data/spec/spec_tests/data/transactions_api/commit.yml +193 -0
- data/spec/spec_tests/data/transactions_api/transaction-options.yml +274 -0
- data/spec/spec_tests/data/transactions_unified/mongos-unpin.yml +172 -0
- data/spec/spec_tests/data/unified/valid-fail/operation-failure.yml +31 -0
- data/spec/spec_tests/data/unified/valid-pass/poc-change-streams.yml +220 -0
- data/spec/spec_tests/data/unified/valid-pass/poc-command-monitoring.yml +102 -0
- data/spec/spec_tests/data/unified/valid-pass/poc-crud.yml +184 -0
- data/spec/spec_tests/data/unified/valid-pass/poc-gridfs.yml +155 -0
- data/spec/spec_tests/data/unified/valid-pass/poc-retryable-reads.yml +193 -0
- data/spec/spec_tests/data/unified/valid-pass/poc-retryable-writes.yml +210 -0
- data/spec/spec_tests/data/unified/valid-pass/poc-sessions.yml +215 -0
- data/spec/spec_tests/data/unified/valid-pass/poc-transactions-convenient-api.yml +235 -0
- data/spec/spec_tests/data/unified/valid-pass/poc-transactions-mongos-pin-auto.yml +169 -0
- data/spec/spec_tests/data/unified/valid-pass/poc-transactions.yml +170 -0
- data/spec/spec_tests/data/uri_options/auth-options.yml +49 -0
- data/spec/spec_tests/data/uri_options/compression-options.yml +51 -0
- data/spec/spec_tests/data/uri_options/concern-options.yml +55 -0
- data/spec/spec_tests/data/uri_options/connection-options.yml +149 -0
- data/spec/spec_tests/data/uri_options/connection-pool-options.yml +26 -0
- data/spec/spec_tests/data/uri_options/read-preference-options.yml +66 -0
- data/spec/spec_tests/data/uri_options/ruby-auth-options.yml +12 -0
- data/spec/spec_tests/data/uri_options/ruby-connection-options.yml +58 -0
- data/spec/spec_tests/data/uri_options/tls-options.yml +364 -0
- data/spec/spec_tests/data/versioned_api/crud-api-version-1-strict.yml +417 -0
- data/spec/spec_tests/data/versioned_api/crud-api-version-1.yml +411 -0
- data/spec/spec_tests/data/versioned_api/runcommand-helper-no-api-version-declared.yml +75 -0
- data/spec/spec_tests/data/versioned_api/test-commands-deprecation-errors.yml +47 -0
- data/spec/spec_tests/data/versioned_api/test-commands-strict-mode.yml +46 -0
- data/spec/spec_tests/data/versioned_api/transaction-handling.yml +128 -0
- data/spec/spec_tests/dns_seedlist_discovery_spec.rb +79 -0
- data/spec/spec_tests/gridfs_spec.rb +55 -0
- data/spec/spec_tests/max_staleness_spec.rb +12 -0
- data/spec/spec_tests/read_write_concern_connection_string_spec.rb +13 -0
- data/spec/spec_tests/read_write_concern_document_spec.rb +77 -0
- data/spec/spec_tests/read_write_concern_operaton_spec.rb +13 -0
- data/spec/spec_tests/retryable_reads_spec.rb +50 -0
- data/spec/spec_tests/retryable_writes_spec.rb +22 -0
- data/spec/spec_tests/sdam_integration_spec.rb +16 -0
- data/spec/spec_tests/sdam_monitoring_spec.rb +96 -0
- data/spec/spec_tests/sdam_spec.rb +242 -0
- data/spec/spec_tests/server_selection_rtt_spec.rb +33 -0
- data/spec/spec_tests/server_selection_spec.rb +12 -0
- data/spec/spec_tests/transactions_api_spec.rb +13 -0
- data/spec/spec_tests/transactions_spec.rb +13 -0
- data/spec/spec_tests/transactions_unified_spec.rb +13 -0
- data/spec/spec_tests/unified_spec.rb +18 -0
- data/spec/spec_tests/uri_options_spec.rb +93 -0
- data/spec/spec_tests/versioned_api_spec.rb +13 -0
- data/spec/stress/cleanup_spec.rb +61 -0
- data/spec/stress/connection_pool_stress_spec.rb +204 -0
- data/spec/stress/connection_pool_timing_spec.rb +184 -0
- data/spec/stress/fork_reconnect_stress_spec.rb +112 -0
- data/spec/stress/push_monitor_close_spec.rb +44 -0
- data/spec/support/authorization.rb +161 -0
- data/spec/support/aws_utils/base.rb +137 -0
- data/spec/support/aws_utils/inspector.rb +227 -0
- data/spec/support/aws_utils/orchestrator.rb +373 -0
- data/spec/support/aws_utils/provisioner.rb +363 -0
- data/spec/support/aws_utils.rb +65 -0
- data/spec/support/background_thread_registry.rb +70 -0
- data/spec/support/certificates/README.md +106 -0
- data/spec/support/certificates/atlas-ocsp-ca.crt +118 -0
- data/spec/support/certificates/atlas-ocsp.crt +152 -0
- data/spec/support/certificates/ca.crt +76 -0
- data/spec/support/certificates/client-encrypted.key +30 -0
- data/spec/support/certificates/client-int.crt +78 -0
- data/spec/support/certificates/client-second-level-bundle.pem +179 -0
- data/spec/support/certificates/client-second-level.crt +74 -0
- data/spec/support/certificates/client-second-level.key +27 -0
- data/spec/support/certificates/client-second-level.pem +101 -0
- data/spec/support/certificates/client-x509.crt +78 -0
- data/spec/support/certificates/client-x509.key +27 -0
- data/spec/support/certificates/client-x509.pem +105 -0
- data/spec/support/certificates/client.crt +74 -0
- data/spec/support/certificates/client.key +27 -0
- data/spec/support/certificates/client.pem +101 -0
- data/spec/support/certificates/crl.pem +12 -0
- data/spec/support/certificates/crl_client_revoked.pem +13 -0
- data/spec/support/certificates/multi-ca.crt +152 -0
- data/spec/support/certificates/python-ca.crt +76 -0
- data/spec/support/certificates/server-int.crt +78 -0
- data/spec/support/certificates/server-second-level-bundle.pem +179 -0
- data/spec/support/certificates/server-second-level.crt +74 -0
- data/spec/support/certificates/server-second-level.key +27 -0
- data/spec/support/certificates/server-second-level.pem +101 -0
- data/spec/support/certificates/server.pem +101 -0
- data/spec/support/client_registry.rb +254 -0
- data/spec/support/client_registry_macros.rb +26 -0
- data/spec/support/cluster_tools.rb +379 -0
- data/spec/support/common_shortcuts.rb +375 -0
- data/spec/support/constraints.rb +19 -0
- data/spec/support/crypt/corpus/corpus-key-aws.json +33 -0
- data/spec/support/crypt/corpus/corpus-key-local.json +31 -0
- data/spec/support/crypt/corpus/corpus-schema.json +2057 -0
- data/spec/support/crypt/corpus/corpus.json +3657 -0
- data/spec/support/crypt/corpus/corpus_encrypted.json +4152 -0
- data/spec/support/crypt/data_keys/key_document_aws.json +34 -0
- data/spec/support/crypt/data_keys/key_document_local.json +31 -0
- data/spec/support/crypt/external/external-key.json +31 -0
- data/spec/support/crypt/external/external-schema.json +19 -0
- data/spec/support/crypt/limits/limits-doc.json +102 -0
- data/spec/support/crypt/limits/limits-key.json +31 -0
- data/spec/support/crypt/limits/limits-schema.json +1405 -0
- data/spec/support/crypt/schema_maps/schema_map_aws.json +17 -0
- data/spec/support/crypt/schema_maps/schema_map_aws_key_alt_names.json +12 -0
- data/spec/support/crypt/schema_maps/schema_map_local.json +18 -0
- data/spec/support/crypt/schema_maps/schema_map_local_key_alt_names.json +12 -0
- data/spec/support/crypt.rb +157 -0
- data/spec/support/dns.rb +16 -0
- data/spec/support/event_subscriber.rb +221 -0
- data/spec/support/json_ext_formatter.rb +16 -0
- data/spec/support/keyword_struct.rb +29 -0
- data/spec/support/local_resource_registry.rb +37 -0
- data/spec/support/matchers.rb +75 -0
- data/spec/support/monitoring_ext.rb +19 -0
- data/spec/support/ocsp +1 -0
- data/spec/support/primary_socket.rb +24 -0
- data/spec/support/sdam_formatter_integration.rb +119 -0
- data/spec/support/session_registry.rb +55 -0
- data/spec/support/shared/app_metadata.rb +167 -0
- data/spec/support/shared/protocol.rb +36 -0
- data/spec/support/shared/scram_conversation.rb +103 -0
- data/spec/support/shared/server_selector.rb +233 -0
- data/spec/support/shared/session.rb +910 -0
- data/spec/support/spec_config.rb +637 -0
- data/spec/support/spec_setup.rb +83 -0
- data/spec/support/utils.rb +598 -0
- data.tar.gz.sig +0 -0
- metadata +2696 -179
- metadata.gz.sig +0 -0
- data/VERSION +0 -1
- data/lib/mongo/db.rb +0 -644
- data/lib/mongo/exceptions.rb +0 -65
- data/lib/mongo/gridfs/grid.rb +0 -101
- data/lib/mongo/gridfs/grid_ext.rb +0 -39
- data/lib/mongo/gridfs/grid_file_system.rb +0 -150
- data/lib/mongo/gridfs/grid_io.rb +0 -472
- data/lib/mongo/legacy.rb +0 -71
- data/lib/mongo/mongo_client.rb +0 -657
- data/lib/mongo/mongo_replica_set_client.rb +0 -485
- data/lib/mongo/mongo_sharded_client.rb +0 -144
- data/lib/mongo/networking.rb +0 -343
- data/lib/mongo/util/conversions.rb +0 -95
- data/lib/mongo/util/core_ext.rb +0 -87
- data/lib/mongo/util/logging.rb +0 -69
- data/lib/mongo/util/node.rb +0 -197
- data/lib/mongo/util/pool.rb +0 -316
- data/lib/mongo/util/pool_manager.rb +0 -270
- data/lib/mongo/util/read_preference.rb +0 -112
- data/lib/mongo/util/server_version.rb +0 -54
- data/lib/mongo/util/sharding_pool_manager.rb +0 -54
- data/lib/mongo/util/socket_util.rb +0 -20
- data/lib/mongo/util/ssl_socket.rb +0 -51
- data/lib/mongo/util/support.rb +0 -113
- data/lib/mongo/util/tcp_socket.rb +0 -62
- data/lib/mongo/util/thread_local_variable_manager.rb +0 -11
- data/lib/mongo/util/unix_socket.rb +0 -23
- data/lib/mongo/util/uri_parser.rb +0 -337
- data/lib/mongo/util/write_concern.rb +0 -54
- data/test/functional/authentication_test.rb +0 -18
- data/test/functional/collection_test.rb +0 -1410
- data/test/functional/connection_test.rb +0 -449
- data/test/functional/conversions_test.rb +0 -119
- data/test/functional/cursor_fail_test.rb +0 -49
- data/test/functional/cursor_message_test.rb +0 -43
- data/test/functional/cursor_test.rb +0 -548
- data/test/functional/db_api_test.rb +0 -805
- data/test/functional/db_connection_test.rb +0 -13
- data/test/functional/db_test.rb +0 -282
- data/test/functional/grid_file_system_test.rb +0 -273
- data/test/functional/grid_io_test.rb +0 -238
- data/test/functional/grid_test.rb +0 -259
- data/test/functional/pool_test.rb +0 -47
- data/test/functional/safe_test.rb +0 -84
- data/test/functional/support_test.rb +0 -48
- data/test/functional/threading_test.rb +0 -95
- data/test/functional/timeout_test.rb +0 -60
- data/test/functional/uri_test.rb +0 -200
- data/test/functional/write_concern_test.rb +0 -104
- data/test/replica_set/authentication_test.rb +0 -20
- data/test/replica_set/basic_test.rb +0 -133
- data/test/replica_set/client_test.rb +0 -264
- data/test/replica_set/complex_connect_test.rb +0 -64
- data/test/replica_set/connection_test.rb +0 -116
- data/test/replica_set/count_test.rb +0 -50
- data/test/replica_set/cursor_test.rb +0 -198
- data/test/replica_set/insert_test.rb +0 -50
- data/test/replica_set/max_values_test.rb +0 -76
- data/test/replica_set/pinning_test.rb +0 -41
- data/test/replica_set/query_test.rb +0 -59
- data/test/replica_set/read_preference_test.rb +0 -200
- data/test/replica_set/refresh_test.rb +0 -161
- data/test/replica_set/replication_ack_test.rb +0 -74
- data/test/sharded_cluster/basic_test.rb +0 -155
- data/test/shared/authentication.rb +0 -66
- data/test/test_helper.rb +0 -210
- data/test/threading/basic_test.rb +0 -80
- data/test/tools/mongo_config.rb +0 -568
- data/test/tools/mongo_config_test.rb +0 -146
- data/test/unit/client_test.rb +0 -252
- data/test/unit/collection_test.rb +0 -176
- data/test/unit/connection_test.rb +0 -246
- data/test/unit/cursor_test.rb +0 -273
- data/test/unit/db_test.rb +0 -112
- data/test/unit/grid_test.rb +0 -62
- data/test/unit/mongo_sharded_client_test.rb +0 -32
- data/test/unit/node_test.rb +0 -78
- data/test/unit/pool_manager_test.rb +0 -94
- data/test/unit/pool_test.rb +0 -9
- data/test/unit/read_pref_test.rb +0 -21
- data/test/unit/read_test.rb +0 -145
- data/test/unit/safe_test.rb +0 -144
- data/test/unit/sharding_pool_manager_test.rb +0 -63
- data/test/unit/util_test.rb +0 -55
- data/test/unit/write_concern_test.rb +0 -161
data/lib/mongo/collection.rb
CHANGED
|
@@ -1,1131 +1,922 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
# encoding: utf-8
|
|
3
|
+
|
|
4
|
+
# Copyright (C) 2014-2020 MongoDB Inc.
|
|
5
|
+
#
|
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
# you may not use this file except in compliance with the License.
|
|
8
|
+
# You may obtain a copy of the License at
|
|
9
|
+
#
|
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
#
|
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
# See the License for the specific language governing permissions and
|
|
16
|
+
# limitations under the License.
|
|
17
|
+
|
|
18
|
+
require 'mongo/bulk_write'
|
|
19
|
+
require 'mongo/collection/view'
|
|
20
|
+
|
|
1
21
|
module Mongo
|
|
2
22
|
|
|
3
|
-
#
|
|
23
|
+
# Represents a collection in the database and operations that can directly be
|
|
24
|
+
# applied to one.
|
|
25
|
+
#
|
|
26
|
+
# @since 2.0.0
|
|
4
27
|
class Collection
|
|
5
|
-
|
|
6
|
-
include
|
|
28
|
+
extend Forwardable
|
|
29
|
+
include Retryable
|
|
7
30
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
:write_concern,
|
|
13
|
-
:capped
|
|
31
|
+
# The capped option.
|
|
32
|
+
#
|
|
33
|
+
# @since 2.1.0
|
|
34
|
+
CAPPED = 'capped'.freeze
|
|
14
35
|
|
|
15
|
-
#
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
36
|
+
# The ns field constant.
|
|
37
|
+
#
|
|
38
|
+
# @since 2.1.0
|
|
39
|
+
NS = 'ns'.freeze
|
|
19
40
|
|
|
20
|
-
#
|
|
21
|
-
|
|
22
|
-
# @param [String, Symbol] name the name of the collection.
|
|
23
|
-
# @param [DB] db a MongoDB database instance.
|
|
24
|
-
#
|
|
25
|
-
# @option opts [String, Integer, Symbol] :w (1) Set default number of nodes to which a write
|
|
26
|
-
# should be acknowledged
|
|
27
|
-
# @option opts [Boolean] :j (false) Set journal acknowledgement
|
|
28
|
-
# @option opts [Integer] :wtimeout (nil) Set replica set acknowledgement timeout
|
|
29
|
-
# @option opts [Boolean] :fsync (false) Set fsync acknowledgement.
|
|
30
|
-
#
|
|
31
|
-
# Notes about write concern:
|
|
32
|
-
# These write concern options will be used for insert, update, and remove methods called on this
|
|
33
|
-
# Collection instance. If no value is provided, the default values set on this instance's DB will be used.
|
|
34
|
-
# These option values can be overridden for any invocation of insert, update, or remove.
|
|
35
|
-
#
|
|
36
|
-
# @option opts [:create_pk] :pk (BSON::ObjectId) A primary key factory to use
|
|
37
|
-
# other than the default BSON::ObjectId.
|
|
38
|
-
# @option opts [:primary, :secondary] :read The default read preference for queries
|
|
39
|
-
# initiates from this connection object. If +:secondary+ is chosen, reads will be sent
|
|
40
|
-
# to one of the closest available secondary nodes. If a secondary node cannot be located, the
|
|
41
|
-
# read will be sent to the primary. If this option is left unspecified, the value of the read
|
|
42
|
-
# preference for this collection's associated Mongo::DB object will be used.
|
|
43
|
-
#
|
|
44
|
-
# @raise [InvalidNSName]
|
|
45
|
-
# if collection name is empty, contains '$', or starts or ends with '.'
|
|
46
|
-
#
|
|
47
|
-
# @raise [TypeError]
|
|
48
|
-
# if collection name is not a string or symbol
|
|
49
|
-
#
|
|
50
|
-
# @return [Collection]
|
|
51
|
-
#
|
|
52
|
-
# @core collections constructor_details
|
|
53
|
-
def initialize(name, db, opts={})
|
|
54
|
-
if db.is_a?(String) && name.is_a?(Mongo::DB)
|
|
55
|
-
warn "Warning: the order of parameters to initialize a collection have changed. " +
|
|
56
|
-
"Please specify the collection name first, followed by the db. This will be made permanent" +
|
|
57
|
-
"in v2.0."
|
|
58
|
-
db, name = name, db
|
|
59
|
-
end
|
|
41
|
+
# @return [ Mongo::Database ] The database the collection resides in.
|
|
42
|
+
attr_reader :database
|
|
60
43
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
name = name.to_s
|
|
44
|
+
# @return [ String ] The name of the collection.
|
|
45
|
+
attr_reader :name
|
|
64
46
|
|
|
65
|
-
|
|
66
|
-
|
|
47
|
+
# @return [ Hash ] The collection options.
|
|
48
|
+
attr_reader :options
|
|
67
49
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
"Collection names must not contain '$'" unless name =~ /((^\$cmd)|(oplog\.\$main))/
|
|
71
|
-
end
|
|
50
|
+
# Get client, cluster, read preference, and write concern from client.
|
|
51
|
+
def_delegators :database, :client, :cluster
|
|
72
52
|
|
|
73
|
-
|
|
74
|
-
|
|
53
|
+
# Delegate to the cluster for the next primary.
|
|
54
|
+
def_delegators :cluster, :next_primary
|
|
75
55
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
pk_factory = opts
|
|
81
|
-
end
|
|
56
|
+
# Options that can be updated on a new Collection instance via the #with method.
|
|
57
|
+
#
|
|
58
|
+
# @since 2.1.0
|
|
59
|
+
CHANGEABLE_OPTIONS = [ :read, :read_concern, :write, :write_concern ].freeze
|
|
82
60
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
unless pk_factory
|
|
89
|
-
@write_concern = get_write_concern(opts, db)
|
|
90
|
-
@read = opts[:read] || @db.read
|
|
91
|
-
Mongo::ReadPreference::validate(@read)
|
|
92
|
-
@capped = opts[:capped]
|
|
93
|
-
@tag_sets = opts.fetch(:tag_sets, @db.tag_sets)
|
|
94
|
-
@acceptable_latency = opts.fetch(:acceptable_latency, @db.acceptable_latency)
|
|
95
|
-
end
|
|
96
|
-
@pk_factory = pk_factory || opts[:pk] || BSON::ObjectId
|
|
97
|
-
@hint = nil
|
|
98
|
-
end
|
|
61
|
+
# Options that can be used for creating a time-series collection.
|
|
62
|
+
TIME_SERIES_OPTIONS = {
|
|
63
|
+
:time_series => :timeseries,
|
|
64
|
+
:expire_after => :expireAfterSeconds
|
|
65
|
+
}
|
|
99
66
|
|
|
100
|
-
#
|
|
67
|
+
# Check if a collection is equal to another object. Will check the name and
|
|
68
|
+
# the database for equality.
|
|
101
69
|
#
|
|
102
|
-
# @
|
|
103
|
-
#
|
|
70
|
+
# @example Check collection equality.
|
|
71
|
+
# collection == other
|
|
104
72
|
#
|
|
105
|
-
# @
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
# @param [String, Symbol] name
|
|
114
|
-
# the collection to return
|
|
115
|
-
#
|
|
116
|
-
# @raise [Mongo::InvalidNSName]
|
|
117
|
-
# if passed an invalid collection name
|
|
118
|
-
#
|
|
119
|
-
# @return [Collection]
|
|
120
|
-
# the specified sub-collection
|
|
121
|
-
def [](name)
|
|
122
|
-
name = "#{self.name}.#{name}"
|
|
123
|
-
return Collection.new(name, db) if !db.strict? ||
|
|
124
|
-
db.collection_names.include?(name.to_s)
|
|
125
|
-
raise "Collection #{name} doesn't exist. Currently in strict mode."
|
|
126
|
-
end
|
|
127
|
-
|
|
128
|
-
# Set a hint field for query optimizer. Hint may be a single field
|
|
129
|
-
# name, array of field names, or a hash (preferably an [OrderedHash]).
|
|
130
|
-
# If using MongoDB > 1.1, you probably don't ever need to set a hint.
|
|
131
|
-
#
|
|
132
|
-
# @param [String, Array, OrderedHash] hint a single field, an array of
|
|
133
|
-
# fields, or a hash specifying fields
|
|
134
|
-
def hint=(hint=nil)
|
|
135
|
-
@hint = normalize_hint_fields(hint)
|
|
136
|
-
self
|
|
137
|
-
end
|
|
138
|
-
|
|
139
|
-
# Set a hint field using a named index.
|
|
140
|
-
# @param [String] hinted index name
|
|
141
|
-
def named_hint=(hint=nil)
|
|
142
|
-
@hint = hint
|
|
143
|
-
self
|
|
73
|
+
# @param [ Object ] other The object to check.
|
|
74
|
+
#
|
|
75
|
+
# @return [ true, false ] If the objects are equal.
|
|
76
|
+
#
|
|
77
|
+
# @since 2.0.0
|
|
78
|
+
def ==(other)
|
|
79
|
+
return false unless other.is_a?(Collection)
|
|
80
|
+
name == other.name && database == other.database && options == other.options
|
|
144
81
|
end
|
|
145
82
|
|
|
146
|
-
#
|
|
147
|
-
#
|
|
148
|
-
#
|
|
149
|
-
#
|
|
150
|
-
#
|
|
151
|
-
#
|
|
152
|
-
#
|
|
153
|
-
#
|
|
154
|
-
#
|
|
155
|
-
#
|
|
156
|
-
#
|
|
157
|
-
#
|
|
158
|
-
#
|
|
159
|
-
#
|
|
160
|
-
#
|
|
161
|
-
#
|
|
162
|
-
#
|
|
163
|
-
#
|
|
164
|
-
#
|
|
165
|
-
#
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
# you can cut down on network traffic and decoding time. If using a Hash, keys should be field
|
|
171
|
-
# names and values should be either 1 or 0, depending on whether you want to include or exclude
|
|
172
|
-
# the given field.
|
|
173
|
-
# @option opts [:primary, :secondary] :read The default read preference for queries
|
|
174
|
-
# initiates from this connection object. If +:secondary+ is chosen, reads will be sent
|
|
175
|
-
# to one of the closest available secondary nodes. If a secondary node cannot be located, the
|
|
176
|
-
# read will be sent to the primary. If this option is left unspecified, the value of the read
|
|
177
|
-
# preference for this Collection object will be used.
|
|
178
|
-
# @option opts [Integer] :skip number of documents to skip from the beginning of the result set
|
|
179
|
-
# @option opts [Integer] :limit maximum number of documents to return
|
|
180
|
-
# @option opts [Array] :sort an array of [key, direction] pairs to sort by. Direction should
|
|
181
|
-
# be specified as Mongo::ASCENDING (or :ascending / :asc) or Mongo::DESCENDING (or :descending / :desc)
|
|
182
|
-
# @option opts [String, Array, OrderedHash] :hint hint for query optimizer, usually not necessary if
|
|
183
|
-
# using MongoDB > 1.1
|
|
184
|
-
# @option opts [String] :named_hint for specifying a named index as a hint, will be overriden by :hint
|
|
185
|
-
# if :hint is also provided.
|
|
186
|
-
# @option opts [Boolean] :snapshot (false) if true, snapshot mode will be used for this query.
|
|
187
|
-
# Snapshot mode assures no duplicates are returned, or objects missed, which were preset at both the start and
|
|
188
|
-
# end of the query's execution.
|
|
189
|
-
# For details see http://www.mongodb.org/display/DOCS/How+to+do+Snapshotting+in+the+Mongo+Database
|
|
190
|
-
# @option opts [Boolean] :batch_size (100) the number of documents to returned by the database per
|
|
191
|
-
# GETMORE operation. A value of 0 will let the database server decide how many results to return.
|
|
192
|
-
# This option can be ignored for most use cases.
|
|
193
|
-
# @option opts [Boolean] :timeout (true) when +true+, the returned cursor will be subject to
|
|
194
|
-
# the normal cursor timeout behavior of the mongod process. When +false+, the returned cursor will
|
|
195
|
-
# never timeout. Note that disabling timeout will only work when #find is invoked with a block.
|
|
196
|
-
# This is to prevent any inadvertent failure to close the cursor, as the cursor is explicitly
|
|
197
|
-
# closed when block code finishes.
|
|
198
|
-
# @option opts [Integer] :max_scan (nil) Limit the number of items to scan on both collection scans and indexed queries..
|
|
199
|
-
# @option opts [Boolean] :show_disk_loc (false) Return the disk location of each query result (for debugging).
|
|
200
|
-
# @option opts [Boolean] :return_key (false) Return the index key used to obtain the result (for debugging).
|
|
201
|
-
# @option opts [Block] :transformer (nil) a block for transforming returned documents.
|
|
202
|
-
# This is normally used by object mappers to convert each returned document to an instance of a class.
|
|
203
|
-
# @option opts [String] :comment (nil) a comment to include in profiling logs
|
|
204
|
-
#
|
|
205
|
-
# @raise [ArgumentError]
|
|
206
|
-
# if timeout is set to false and find is not invoked in a block
|
|
207
|
-
#
|
|
208
|
-
# @raise [RuntimeError]
|
|
209
|
-
# if given unknown options
|
|
210
|
-
#
|
|
211
|
-
# @core find find-instance_method
|
|
212
|
-
def find(selector={}, opts={})
|
|
213
|
-
opts = opts.dup
|
|
214
|
-
fields = opts.delete(:fields)
|
|
215
|
-
fields = ["_id"] if fields && fields.empty?
|
|
216
|
-
skip = opts.delete(:skip) || skip || 0
|
|
217
|
-
limit = opts.delete(:limit) || 0
|
|
218
|
-
sort = opts.delete(:sort)
|
|
219
|
-
hint = opts.delete(:hint)
|
|
220
|
-
named_hint = opts.delete(:named_hint)
|
|
221
|
-
snapshot = opts.delete(:snapshot)
|
|
222
|
-
batch_size = opts.delete(:batch_size)
|
|
223
|
-
timeout = (opts.delete(:timeout) == false) ? false : true
|
|
224
|
-
max_scan = opts.delete(:max_scan)
|
|
225
|
-
return_key = opts.delete(:return_key)
|
|
226
|
-
transformer = opts.delete(:transformer)
|
|
227
|
-
show_disk_loc = opts.delete(:show_disk_loc)
|
|
228
|
-
comment = opts.delete(:comment)
|
|
229
|
-
read = opts.delete(:read) || @read
|
|
230
|
-
tag_sets = opts.delete(:tag_sets) || @tag_sets
|
|
231
|
-
acceptable_latency = opts.delete(:acceptable_latency) || @acceptable_latency
|
|
232
|
-
|
|
233
|
-
if timeout == false && !block_given?
|
|
234
|
-
raise ArgumentError, "Collection#find must be invoked with a block when timeout is disabled."
|
|
235
|
-
end
|
|
236
|
-
|
|
237
|
-
if hint
|
|
238
|
-
hint = normalize_hint_fields(hint)
|
|
239
|
-
else
|
|
240
|
-
hint = @hint # assumed to be normalized already
|
|
83
|
+
# Instantiate a new collection.
|
|
84
|
+
#
|
|
85
|
+
# @example Instantiate a new collection.
|
|
86
|
+
# Mongo::Collection.new(database, 'test')
|
|
87
|
+
#
|
|
88
|
+
# @param [ Mongo::Database ] database The collection's database.
|
|
89
|
+
# @param [ String, Symbol ] name The collection name.
|
|
90
|
+
# @param [ Hash ] options The collection options.
|
|
91
|
+
#
|
|
92
|
+
# @option options [ Hash ] :write Deprecated. Equivalent to :write_concern
|
|
93
|
+
# option.
|
|
94
|
+
# @option options [ Hash ] :write_concern The write concern options.
|
|
95
|
+
# Can be :w => Integer|String, :fsync => Boolean, :j => Boolean.
|
|
96
|
+
# @option options [ Hash ] :time_series Create a time-series collection.
|
|
97
|
+
# See https://docs.mongodb.com/manual/core/timeseries-collections/ for more
|
|
98
|
+
# information about time-series collection.
|
|
99
|
+
# @option options [ Integer ] :expire_after Number indicating
|
|
100
|
+
# after how many seconds old time-series data should be deleted.
|
|
101
|
+
#
|
|
102
|
+
# @since 2.0.0
|
|
103
|
+
def initialize(database, name, options = {})
|
|
104
|
+
raise Error::InvalidCollectionName.new unless name
|
|
105
|
+
if options[:write] && options[:write_concern] && options[:write] != options[:write_concern]
|
|
106
|
+
raise ArgumentError, "If :write and :write_concern are both given, they must be identical: #{options.inspect}"
|
|
241
107
|
end
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
:
|
|
249
|
-
:
|
|
250
|
-
:order => sort,
|
|
251
|
-
:hint => hint || named_hint,
|
|
252
|
-
:snapshot => snapshot,
|
|
253
|
-
:timeout => timeout,
|
|
254
|
-
:batch_size => batch_size,
|
|
255
|
-
:transformer => transformer,
|
|
256
|
-
:max_scan => max_scan,
|
|
257
|
-
:show_disk_loc => show_disk_loc,
|
|
258
|
-
:return_key => return_key,
|
|
259
|
-
:read => read,
|
|
260
|
-
:tag_sets => tag_sets,
|
|
261
|
-
:comment => comment,
|
|
262
|
-
:acceptable_latency => acceptable_latency
|
|
263
|
-
})
|
|
264
|
-
|
|
265
|
-
if block_given?
|
|
266
|
-
begin
|
|
267
|
-
yield cursor
|
|
268
|
-
ensure
|
|
269
|
-
cursor.close
|
|
270
|
-
end
|
|
271
|
-
nil
|
|
272
|
-
else
|
|
273
|
-
cursor
|
|
108
|
+
@database = database
|
|
109
|
+
@name = name.to_s.freeze
|
|
110
|
+
@options = options.dup
|
|
111
|
+
=begin WriteConcern object support
|
|
112
|
+
if @options[:write_concern].is_a?(WriteConcern::Base)
|
|
113
|
+
# Cache the instance so that we do not needlessly reconstruct it.
|
|
114
|
+
@write_concern = @options[:write_concern]
|
|
115
|
+
@options[:write_concern] = @write_concern.options
|
|
274
116
|
end
|
|
117
|
+
=end
|
|
118
|
+
@options.freeze
|
|
275
119
|
end
|
|
276
120
|
|
|
277
|
-
#
|
|
278
|
-
#
|
|
279
|
-
# @
|
|
280
|
-
#
|
|
281
|
-
#
|
|
282
|
-
# @
|
|
283
|
-
#
|
|
284
|
-
#
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
# @option opts [Hash]
|
|
288
|
-
# any valid options that can be send to Collection#find
|
|
289
|
-
#
|
|
290
|
-
# @raise [TypeError]
|
|
291
|
-
# if the argument is of an improper type.
|
|
292
|
-
def find_one(spec_or_object_id=nil, opts={})
|
|
293
|
-
spec = case spec_or_object_id
|
|
294
|
-
when nil
|
|
295
|
-
{}
|
|
296
|
-
when BSON::ObjectId
|
|
297
|
-
{:_id => spec_or_object_id}
|
|
298
|
-
when Hash
|
|
299
|
-
spec_or_object_id
|
|
300
|
-
else
|
|
301
|
-
raise TypeError, "spec_or_object_id must be an instance of ObjectId or Hash, or nil"
|
|
302
|
-
end
|
|
303
|
-
find(spec, opts.merge(:limit => -1)).next_document
|
|
304
|
-
end
|
|
305
|
-
|
|
306
|
-
# Save a document to this collection.
|
|
307
|
-
#
|
|
308
|
-
# @param [Hash] doc
|
|
309
|
-
# the document to be saved. If the document already has an '_id' key,
|
|
310
|
-
# then an update (upsert) operation will be performed, and any existing
|
|
311
|
-
# document with that _id is overwritten. Otherwise an insert operation is performed.
|
|
312
|
-
#
|
|
313
|
-
# @return [ObjectId] the _id of the saved document.
|
|
314
|
-
#
|
|
315
|
-
# @option opts [Hash] :w, :j, :wtimeout, :fsync Set the write concern for this operation.
|
|
316
|
-
# :w > 0 will run a +getlasterror+ command on the database to report any assertion.
|
|
317
|
-
# :j will confirm a write has been committed to the journal,
|
|
318
|
-
# :wtimeout specifies how long to wait for write confirmation,
|
|
319
|
-
# :fsync will confirm that a write has been fsynced.
|
|
320
|
-
# Options provided here will override any write concern options set on this collection,
|
|
321
|
-
# its database object, or the current connection. See the options
|
|
322
|
-
# for DB#get_last_error.
|
|
323
|
-
#
|
|
324
|
-
# @raise [Mongo::OperationFailure] will be raised iff :w > 0 and the operation fails.
|
|
325
|
-
def save(doc, opts={})
|
|
326
|
-
if doc.has_key?(:_id) || doc.has_key?('_id')
|
|
327
|
-
id = doc[:_id] || doc['_id']
|
|
328
|
-
update({:_id => id}, doc, opts.merge!({:upsert => true}))
|
|
329
|
-
id
|
|
330
|
-
else
|
|
331
|
-
insert(doc, opts)
|
|
332
|
-
end
|
|
121
|
+
# Get the read concern for this collection instance.
|
|
122
|
+
#
|
|
123
|
+
# @example Get the read concern.
|
|
124
|
+
# collection.read_concern
|
|
125
|
+
#
|
|
126
|
+
# @return [ Hash ] The read concern.
|
|
127
|
+
#
|
|
128
|
+
# @since 2.2.0
|
|
129
|
+
def read_concern
|
|
130
|
+
options[:read_concern] || database.read_concern
|
|
333
131
|
end
|
|
334
132
|
|
|
335
|
-
#
|
|
336
|
-
#
|
|
337
|
-
# @
|
|
338
|
-
#
|
|
339
|
-
#
|
|
340
|
-
# @return [
|
|
341
|
-
#
|
|
342
|
-
# @
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
# Return this result format only when :collect_on_error is true.
|
|
346
|
-
#
|
|
347
|
-
# @option opts [String, Integer, Symbol] :w (1) Set default number of nodes to which a write
|
|
348
|
-
# should be acknowledged
|
|
349
|
-
# @option opts [Boolean] :j (false) Set journal acknowledgement
|
|
350
|
-
# @option opts [Integer] :wtimeout (nil) Set replica set acknowledgement timeout
|
|
351
|
-
# @option opts [Boolean] :fsync (false) Set fsync acknowledgement.
|
|
352
|
-
#
|
|
353
|
-
# Notes on write concern:
|
|
354
|
-
# Options provided here will override any write concern options set on this collection,
|
|
355
|
-
# its database object, or the current connection. See the options for +DB#get_last_error+.
|
|
356
|
-
#
|
|
357
|
-
# @option opts [Boolean] :continue_on_error (+false+) If true, then
|
|
358
|
-
# continue a bulk insert even if one of the documents inserted
|
|
359
|
-
# triggers a database assertion (as in a duplicate insert, for instance).
|
|
360
|
-
# If not acknowledging writes, the list of ids returned will
|
|
361
|
-
# include the object ids of all documents attempted on insert, even
|
|
362
|
-
# if some are rejected on error. When acknowledging writes, any error will raise an
|
|
363
|
-
# OperationFailure exception.
|
|
364
|
-
# MongoDB v2.0+.
|
|
365
|
-
# @option opts [Boolean] :collect_on_error (+false+) if true, then
|
|
366
|
-
# collects invalid documents as an array. Note that this option changes the result format.
|
|
367
|
-
#
|
|
368
|
-
# @raise [Mongo::OperationFailure] will be raised iff :w > 0 and the operation fails.
|
|
369
|
-
#
|
|
370
|
-
# @core insert insert-instance_method
|
|
371
|
-
def insert(doc_or_docs, opts={})
|
|
372
|
-
doc_or_docs = [doc_or_docs] unless doc_or_docs.is_a?(Array)
|
|
373
|
-
doc_or_docs.collect! { |doc| @pk_factory.create_pk(doc) }
|
|
374
|
-
write_concern = get_write_concern(opts, self)
|
|
375
|
-
result = insert_documents(doc_or_docs, @name, true, write_concern, opts)
|
|
376
|
-
result.size > 1 ? result : result.first
|
|
133
|
+
# Get the server selector on this collection.
|
|
134
|
+
#
|
|
135
|
+
# @example Get the server selector.
|
|
136
|
+
# collection.server_selector
|
|
137
|
+
#
|
|
138
|
+
# @return [ Mongo::ServerSelector ] The server selector.
|
|
139
|
+
#
|
|
140
|
+
# @since 2.0.0
|
|
141
|
+
def server_selector
|
|
142
|
+
@server_selector ||= ServerSelector.get(read_preference || database.server_selector)
|
|
377
143
|
end
|
|
378
|
-
alias_method :<<, :insert
|
|
379
144
|
|
|
380
|
-
#
|
|
145
|
+
# Get the read preference on this collection.
|
|
381
146
|
#
|
|
382
|
-
# @
|
|
383
|
-
#
|
|
147
|
+
# @example Get the read preference.
|
|
148
|
+
# collection.read_preference
|
|
384
149
|
#
|
|
385
|
-
# @
|
|
386
|
-
# should be acknowledged
|
|
387
|
-
# @option opts [Boolean] :j (false) Set journal acknowledgement
|
|
388
|
-
# @option opts [Integer] :wtimeout (nil) Set replica set acknowledgement timeout
|
|
389
|
-
# @option opts [Boolean] :fsync (false) Set fsync acknowledgement.
|
|
150
|
+
# @return [ Hash ] The read preference.
|
|
390
151
|
#
|
|
391
|
-
#
|
|
392
|
-
|
|
393
|
-
|
|
152
|
+
# @since 2.0.0
|
|
153
|
+
def read_preference
|
|
154
|
+
@read_preference ||= options[:read] || database.read_preference
|
|
155
|
+
end
|
|
156
|
+
|
|
157
|
+
# Get the write concern on this collection.
|
|
394
158
|
#
|
|
395
|
-
# @example
|
|
396
|
-
#
|
|
397
|
-
# users.remove({})
|
|
159
|
+
# @example Get the write concern.
|
|
160
|
+
# collection.write_concern
|
|
398
161
|
#
|
|
399
|
-
# @
|
|
400
|
-
# users.remove({:expire => {"$lte" => Time.now}})
|
|
162
|
+
# @return [ Mongo::WriteConcern ] The write concern.
|
|
401
163
|
#
|
|
402
|
-
# @
|
|
403
|
-
|
|
164
|
+
# @since 2.0.0
|
|
165
|
+
def write_concern
|
|
166
|
+
@write_concern ||= WriteConcern.get(
|
|
167
|
+
options[:write_concern] || options[:write] || database.write_concern)
|
|
168
|
+
end
|
|
169
|
+
|
|
170
|
+
# Get the write concern for the collection, given the session.
|
|
404
171
|
#
|
|
405
|
-
#
|
|
172
|
+
# If the session is in a transaction and the collection
|
|
173
|
+
# has an unacknowledged write concern, remove the write
|
|
174
|
+
# concern's :w option. Otherwise, return the unmodified
|
|
175
|
+
# write concern.
|
|
406
176
|
#
|
|
407
|
-
# @
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
@connection.send_message_with_gle(Mongo::Constants::OP_DELETE, message, @db.name, nil, write_concern)
|
|
418
|
-
else
|
|
419
|
-
@connection.send_message(Mongo::Constants::OP_DELETE, message)
|
|
420
|
-
true
|
|
177
|
+
# @return [ Mongo::WriteConcern ] The write concern.
|
|
178
|
+
#
|
|
179
|
+
# @api private
|
|
180
|
+
def write_concern_with_session(session)
|
|
181
|
+
wc = write_concern
|
|
182
|
+
if session && session.in_transaction?
|
|
183
|
+
if wc && !wc.acknowledged?
|
|
184
|
+
opts = wc.options.dup
|
|
185
|
+
opts.delete(:w)
|
|
186
|
+
return WriteConcern.get(opts)
|
|
421
187
|
end
|
|
422
188
|
end
|
|
189
|
+
wc
|
|
423
190
|
end
|
|
424
191
|
|
|
425
|
-
#
|
|
426
|
-
#
|
|
427
|
-
#
|
|
428
|
-
#
|
|
429
|
-
#
|
|
430
|
-
#
|
|
431
|
-
#
|
|
432
|
-
#
|
|
433
|
-
# a hash specifying the fields to be changed in the selected document,
|
|
434
|
-
# or (in the case of an upsert) the document to be inserted
|
|
435
|
-
#
|
|
436
|
-
# @option opts [Boolean] :upsert (+false+) if true, performs an upsert (update or insert)
|
|
437
|
-
# @option opts [Boolean] :multi (+false+) update all documents matching the selector, as opposed to
|
|
438
|
-
# just the first matching document. Note: only works in MongoDB 1.1.3 or later.
|
|
439
|
-
# @option opts [String, Integer, Symbol] :w (1) Set default number of nodes to which a write
|
|
440
|
-
# should be acknowledged
|
|
441
|
-
# @option opts [Boolean] :j (false) Set journal acknowledgement
|
|
442
|
-
# @option opts [Integer] :wtimeout (nil) Set replica set acknowledgement timeout
|
|
443
|
-
# @option opts [Boolean] :fsync (false) Set fsync acknowledgement.
|
|
444
|
-
#
|
|
445
|
-
# Notes on write concern:
|
|
446
|
-
# Options provided here will override any write concern options set on this collection,
|
|
447
|
-
# its database object, or the current connection. See the options for DB#get_last_error.
|
|
448
|
-
#
|
|
449
|
-
# @return [Hash, true] Returns a Hash containing the last error object if acknowledging writes.
|
|
450
|
-
# Otherwise, returns true.
|
|
451
|
-
#
|
|
452
|
-
# @raise [Mongo::OperationFailure] will be raised iff :w > 0 and the operation fails.
|
|
453
|
-
#
|
|
454
|
-
# @core update update-instance_method
|
|
455
|
-
def update(selector, document, opts={})
|
|
456
|
-
# Initial byte is 0.
|
|
457
|
-
write_concern = get_write_concern(opts, self)
|
|
458
|
-
message = BSON::ByteBuffer.new("\0\0\0\0", @connection.max_message_size)
|
|
459
|
-
BSON::BSON_RUBY.serialize_cstr(message, "#{@db.name}.#{@name}")
|
|
460
|
-
update_options = 0
|
|
461
|
-
update_options += 1 if opts[:upsert]
|
|
462
|
-
update_options += 2 if opts[:multi]
|
|
463
|
-
|
|
464
|
-
# Determine if update document has modifiers and check keys if so
|
|
465
|
-
check_keys = document.keys.first.to_s.start_with?("$") ? false : true
|
|
466
|
-
|
|
467
|
-
message.put_int(update_options)
|
|
468
|
-
message.put_binary(BSON::BSON_CODER.serialize(selector, false, true, @connection.max_bson_size).to_s)
|
|
469
|
-
message.put_binary(BSON::BSON_CODER.serialize(document, check_keys, true, @connection.max_bson_size).to_s)
|
|
192
|
+
# Provides a new collection with either a new read preference or new write concern
|
|
193
|
+
# merged over the existing read preference / write concern.
|
|
194
|
+
#
|
|
195
|
+
# @example Get a collection with a changed read preference.
|
|
196
|
+
# collection.with(read: { mode: :primary_preferred })
|
|
197
|
+
#
|
|
198
|
+
# @example Get a collection with a changed write concern.
|
|
199
|
+
# collection.with(write_concern: { w: 3 })
|
|
470
200
|
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
201
|
+
# @param [ Hash ] new_options The new options to use.
|
|
202
|
+
#
|
|
203
|
+
# @return [ Mongo::Collection ] A new collection instance.
|
|
204
|
+
#
|
|
205
|
+
# @since 2.1.0
|
|
206
|
+
def with(new_options)
|
|
207
|
+
new_options.keys.each do |k|
|
|
208
|
+
raise Error::UnchangeableCollectionOption.new(k) unless CHANGEABLE_OPTIONS.include?(k)
|
|
477
209
|
end
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
#
|
|
482
|
-
# @param [String, Array] spec
|
|
483
|
-
# should be either a single field name or an array of
|
|
484
|
-
# [field name, type] pairs. Index types should be specified
|
|
485
|
-
# as Mongo::ASCENDING, Mongo::DESCENDING, Mongo::GEO2D, Mongo::GEO2DSPHERE, Mongo::GEOHAYSTACK,
|
|
486
|
-
# Mongo::TEXT or Mongo::HASHED.
|
|
487
|
-
#
|
|
488
|
-
# Note that geospatial indexing only works with versions of MongoDB >= 1.3.3+. Keep in mind, too,
|
|
489
|
-
# that in order to geo-index a given field, that field must reference either an array or a sub-object
|
|
490
|
-
# where the first two values represent x- and y-coordinates. Examples can be seen below.
|
|
491
|
-
#
|
|
492
|
-
# Also note that it is permissible to create compound indexes that include a geospatial index as
|
|
493
|
-
# long as the geospatial index comes first.
|
|
494
|
-
#
|
|
495
|
-
# If your code calls create_index frequently, you can use Collection#ensure_index to cache these calls
|
|
496
|
-
# and thereby prevent excessive round trips to the database.
|
|
497
|
-
#
|
|
498
|
-
# @option opts [Boolean] :unique (false) if true, this index will enforce a uniqueness constraint.
|
|
499
|
-
# @option opts [Boolean] :background (false) indicate that the index should be built in the background. This
|
|
500
|
-
# feature is only available in MongoDB >= 1.3.2.
|
|
501
|
-
# @option opts [Boolean] :drop_dups (nil) If creating a unique index on a collection with pre-existing records,
|
|
502
|
-
# this option will keep the first document the database indexes and drop all subsequent with duplicate values.
|
|
503
|
-
# @option opts [Integer] :bucket_size (nil) For use with geoHaystack indexes. Number of documents to group
|
|
504
|
-
# together within a certain proximity to a given longitude and latitude.
|
|
505
|
-
# @option opts [Integer] :min (nil) specify the minimum longitude and latitude for a geo index.
|
|
506
|
-
# @option opts [Integer] :max (nil) specify the maximum longitude and latitude for a geo index.
|
|
507
|
-
#
|
|
508
|
-
# @example Creating a compound index using a hash: (Ruby 1.9+ Syntax)
|
|
509
|
-
# @posts.create_index({'subject' => Mongo::ASCENDING, 'created_at' => Mongo::DESCENDING})
|
|
510
|
-
#
|
|
511
|
-
# @example Creating a compound index:
|
|
512
|
-
# @posts.create_index([['subject', Mongo::ASCENDING], ['created_at', Mongo::DESCENDING]])
|
|
513
|
-
#
|
|
514
|
-
# @example Creating a geospatial index using a hash: (Ruby 1.9+ Syntax)
|
|
515
|
-
# @restaurants.create_index(:location => Mongo::GEO2D)
|
|
516
|
-
#
|
|
517
|
-
# @example Creating a geospatial index:
|
|
518
|
-
# @restaurants.create_index([['location', Mongo::GEO2D]])
|
|
519
|
-
#
|
|
520
|
-
# # Note that this will work only if 'location' represents x,y coordinates:
|
|
521
|
-
# {'location': [0, 50]}
|
|
522
|
-
# {'location': {'x' => 0, 'y' => 50}}
|
|
523
|
-
# {'location': {'latitude' => 0, 'longitude' => 50}}
|
|
524
|
-
#
|
|
525
|
-
# @example A geospatial index with alternate longitude and latitude:
|
|
526
|
-
# @restaurants.create_index([['location', Mongo::GEO2D]], :min => 500, :max => 500)
|
|
527
|
-
#
|
|
528
|
-
# @return [String] the name of the index created.
|
|
529
|
-
#
|
|
530
|
-
# @core indexes create_index-instance_method
|
|
531
|
-
def create_index(spec, opts={})
|
|
532
|
-
opts[:dropDups] = opts[:drop_dups] if opts[:drop_dups]
|
|
533
|
-
opts[:bucketSize] = opts[:bucket_size] if opts[:bucket_size]
|
|
534
|
-
field_spec = parse_index_spec(spec)
|
|
535
|
-
opts = opts.dup
|
|
536
|
-
name = opts.delete(:name) || generate_index_name(field_spec)
|
|
537
|
-
name = name.to_s if name
|
|
538
|
-
generate_indexes(field_spec, name, opts)
|
|
539
|
-
name
|
|
540
|
-
end
|
|
541
|
-
|
|
542
|
-
# Calls create_index and sets a flag to not do so again for another X minutes.
|
|
543
|
-
# this time can be specified as an option when initializing a Mongo::DB object as options[:cache_time]
|
|
544
|
-
# Any changes to an index will be propagated through regardless of cache time (e.g., a change of index direction)
|
|
545
|
-
#
|
|
546
|
-
# The parameters and options for this methods are the same as those for Collection#create_index.
|
|
547
|
-
#
|
|
548
|
-
# @example Call sequence (Ruby 1.9+ Syntax):
|
|
549
|
-
# Time t: @posts.ensure_index(:subject => Mongo::ASCENDING) -- calls create_index and
|
|
550
|
-
# sets the 5 minute cache
|
|
551
|
-
# Time t+2min : @posts.ensure_index(:subject => Mongo::ASCENDING) -- doesn't do anything
|
|
552
|
-
# Time t+3min : @posts.ensure_index(:something_else => Mongo::ASCENDING) -- calls create_index
|
|
553
|
-
# and sets 5 minute cache
|
|
554
|
-
# Time t+10min : @posts.ensure_index(:subject => Mongo::ASCENDING) -- calls create_index and
|
|
555
|
-
# resets the 5 minute counter
|
|
556
|
-
#
|
|
557
|
-
# @return [String] the name of the index.
|
|
558
|
-
def ensure_index(spec, opts={})
|
|
559
|
-
now = Time.now.utc.to_i
|
|
560
|
-
opts[:dropDups] = opts[:drop_dups] if opts[:drop_dups]
|
|
561
|
-
opts[:bucketSize] = opts[:bucket_size] if opts[:bucket_size]
|
|
562
|
-
field_spec = parse_index_spec(spec)
|
|
563
|
-
name = opts[:name] || generate_index_name(field_spec)
|
|
564
|
-
name = name.to_s if name
|
|
565
|
-
|
|
566
|
-
if !@cache[name] || @cache[name] <= now
|
|
567
|
-
generate_indexes(field_spec, name, opts)
|
|
210
|
+
options = @options.dup
|
|
211
|
+
if options[:write] && new_options[:write_concern]
|
|
212
|
+
options.delete(:write)
|
|
568
213
|
end
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
name
|
|
214
|
+
if options[:write_concern] && new_options[:write]
|
|
215
|
+
options.delete(:write_concern)
|
|
216
|
+
end
|
|
217
|
+
Collection.new(database, name, options.update(new_options))
|
|
573
218
|
end
|
|
574
219
|
|
|
575
|
-
#
|
|
220
|
+
# Is the collection capped?
|
|
221
|
+
#
|
|
222
|
+
# @example Is the collection capped?
|
|
223
|
+
# collection.capped?
|
|
576
224
|
#
|
|
577
|
-
# @
|
|
225
|
+
# @return [ true, false ] If the collection is capped.
|
|
578
226
|
#
|
|
579
|
-
# @
|
|
580
|
-
def
|
|
581
|
-
|
|
582
|
-
|
|
227
|
+
# @since 2.0.0
|
|
228
|
+
def capped?
|
|
229
|
+
database.read_command(:collstats => name).documents[0][CAPPED]
|
|
230
|
+
end
|
|
231
|
+
|
|
232
|
+
# Force the collection to be created in the database.
|
|
233
|
+
#
|
|
234
|
+
# @example Force the collection to be created.
|
|
235
|
+
# collection.create
|
|
236
|
+
#
|
|
237
|
+
# @param [ Hash ] opts The options for the create operation.
|
|
238
|
+
#
|
|
239
|
+
# @option opts [ Session ] :session The session to use for the operation.
|
|
240
|
+
# @option opts [ Hash ] :write_concern The write concern options.
|
|
241
|
+
# @option opts [ Hash ] :time_series Create a time-series collection.
|
|
242
|
+
# @option opts [ Integer ] :expire_after Number indicating
|
|
243
|
+
# after how many seconds old time-series data should be deleted.
|
|
244
|
+
#
|
|
245
|
+
# @return [ Result ] The result of the command.
|
|
246
|
+
#
|
|
247
|
+
# @since 2.0.0
|
|
248
|
+
def create(opts = {})
|
|
249
|
+
# Passing read options to create command causes it to break.
|
|
250
|
+
# Filter the read options out.
|
|
251
|
+
# TODO put the list of read options in a class-level constant when
|
|
252
|
+
# we figure out what the full set of them is.
|
|
253
|
+
options = Hash[self.options.reject do |key, value|
|
|
254
|
+
%w(read read_preference).include?(key.to_s)
|
|
255
|
+
end]
|
|
256
|
+
options.update(Utils.slice_hash(opts, *TIME_SERIES_OPTIONS.keys))
|
|
257
|
+
# Converting Ruby spelled time series options to server style.
|
|
258
|
+
TIME_SERIES_OPTIONS.each do |ruby_key, server_key|
|
|
259
|
+
if options.key?(ruby_key)
|
|
260
|
+
options[server_key] = options.delete(ruby_key)
|
|
261
|
+
end
|
|
262
|
+
end
|
|
263
|
+
operation = { :create => name }.merge(options)
|
|
264
|
+
operation.delete(:write)
|
|
265
|
+
operation.delete(:write_concern)
|
|
266
|
+
client.send(:with_session, opts) do |session|
|
|
267
|
+
write_concern = if opts[:write_concern]
|
|
268
|
+
WriteConcern.get(opts[:write_concern])
|
|
269
|
+
else
|
|
270
|
+
self.write_concern
|
|
271
|
+
end
|
|
272
|
+
server = next_primary(nil, session)
|
|
273
|
+
if (options[:collation] || options[Operation::COLLATION]) && !server.with_connection { |connection| connection.features }.collation_enabled?
|
|
274
|
+
raise Error::UnsupportedCollation
|
|
275
|
+
end
|
|
276
|
+
|
|
277
|
+
Operation::Create.new({
|
|
278
|
+
selector: operation,
|
|
279
|
+
db_name: database.name,
|
|
280
|
+
write_concern: write_concern,
|
|
281
|
+
session: session,
|
|
282
|
+
}).execute(server, context: Operation::Context.new(client: client, session: session))
|
|
583
283
|
end
|
|
584
|
-
@cache[name.to_s] = nil
|
|
585
|
-
@db.drop_index(@name, name)
|
|
586
284
|
end
|
|
587
285
|
|
|
588
|
-
# Drop all indexes
|
|
286
|
+
# Drop the collection. Will also drop all indexes associated with the
|
|
287
|
+
# collection.
|
|
589
288
|
#
|
|
590
|
-
# @
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
289
|
+
# @note An error returned if the collection doesn't exist is suppressed.
|
|
290
|
+
#
|
|
291
|
+
# @example Drop the collection.
|
|
292
|
+
# collection.drop
|
|
293
|
+
#
|
|
294
|
+
# @param [ Hash ] opts The options for the drop operation.
|
|
295
|
+
#
|
|
296
|
+
# @option options [ Session ] :session The session to use for the operation.
|
|
297
|
+
# @option opts [ Hash ] :write_concern The write concern options.
|
|
298
|
+
#
|
|
299
|
+
# @return [ Result ] The result of the command.
|
|
300
|
+
#
|
|
301
|
+
# @since 2.0.0
|
|
302
|
+
def drop(opts = {})
|
|
303
|
+
client.send(:with_session, opts) do |session|
|
|
304
|
+
temp_write_concern = write_concern
|
|
305
|
+
write_concern = if opts[:write_concern]
|
|
306
|
+
WriteConcern.get(opts[:write_concern])
|
|
307
|
+
else
|
|
308
|
+
temp_write_concern
|
|
309
|
+
end
|
|
310
|
+
Operation::Drop.new({
|
|
311
|
+
selector: { :drop => name },
|
|
312
|
+
db_name: database.name,
|
|
313
|
+
write_concern: write_concern,
|
|
314
|
+
session: session,
|
|
315
|
+
}).execute(next_primary(nil, session), context: Operation::Context.new(client: client, session: session))
|
|
316
|
+
end
|
|
317
|
+
rescue Error::OperationFailure => ex
|
|
318
|
+
# NamespaceNotFound
|
|
319
|
+
if ex.code == 26 || ex.code.nil? && ex.message =~ /ns not found/
|
|
320
|
+
false
|
|
321
|
+
else
|
|
322
|
+
raise
|
|
323
|
+
end
|
|
324
|
+
end
|
|
325
|
+
|
|
326
|
+
# Find documents in the collection.
|
|
327
|
+
#
|
|
328
|
+
# @example Find documents in the collection by a selector.
|
|
329
|
+
# collection.find(name: 1)
|
|
330
|
+
#
|
|
331
|
+
# @example Get all documents in a collection.
|
|
332
|
+
# collection.find
|
|
333
|
+
#
|
|
334
|
+
# @param [ Hash ] filter The filter to use in the find.
|
|
335
|
+
# @param [ Hash ] options The options for the find.
|
|
336
|
+
#
|
|
337
|
+
# @option options [ true, false ] :allow_disk_use When set to true, the
|
|
338
|
+
# server can write temporary data to disk while executing the find
|
|
339
|
+
# operation. This option is only available on MongoDB server versions
|
|
340
|
+
# 4.4 and newer.
|
|
341
|
+
# @option options [ true, false ] :allow_partial_results Allows the query to get partial
|
|
342
|
+
# results if some shards are down.
|
|
343
|
+
# @option options [ Integer ] :batch_size The number of documents returned in each batch
|
|
344
|
+
# of results from MongoDB.
|
|
345
|
+
# @option options [ Hash ] :collation The collation to use.
|
|
346
|
+
# @option options [ String ] :comment Associate a comment with the query.
|
|
347
|
+
# @option options [ :tailable, :tailable_await ] :cursor_type The type of cursor to use.
|
|
348
|
+
# @option options [ Integer ] :limit The max number of docs to return from the query.
|
|
349
|
+
# @option options [ Integer ] :max_time_ms
|
|
350
|
+
# The maximum amount of time to allow the query to run, in milliseconds.
|
|
351
|
+
# @option options [ Hash ] :modifiers A document containing meta-operators modifying the
|
|
352
|
+
# output or behavior of a query.
|
|
353
|
+
# @option options [ true, false ] :no_cursor_timeout The server normally times out idle
|
|
354
|
+
# cursors after an inactivity period (10 minutes) to prevent excess memory use.
|
|
355
|
+
# Set this option to prevent that.
|
|
356
|
+
# @option options [ true, false ] :oplog_replay Internal replication use only - driver
|
|
357
|
+
# should not set.
|
|
358
|
+
# @option options [ Hash ] :projection The fields to include or exclude from each doc
|
|
359
|
+
# in the result set.
|
|
360
|
+
# @option options [ Session ] :session The session to use.
|
|
361
|
+
# @option options [ Integer ] :skip The number of docs to skip before returning results.
|
|
362
|
+
# @option options [ Hash ] :sort The key and direction pairs by which the result set
|
|
363
|
+
# will be sorted.
|
|
364
|
+
#
|
|
365
|
+
# @return [ CollectionView ] The collection view.
|
|
366
|
+
#
|
|
367
|
+
# @since 2.0.0
|
|
368
|
+
def find(filter = nil, options = {})
|
|
369
|
+
View.new(self, filter || {}, options)
|
|
370
|
+
end
|
|
371
|
+
|
|
372
|
+
# Perform an aggregation on the collection.
|
|
373
|
+
#
|
|
374
|
+
# @example Perform an aggregation.
|
|
375
|
+
# collection.aggregate([ { "$group" => { "_id" => "$city", "tpop" => { "$sum" => "$pop" }}} ])
|
|
376
|
+
#
|
|
377
|
+
# @param [ Array<Hash> ] pipeline The aggregation pipeline.
|
|
378
|
+
# @param [ Hash ] options The aggregation options.
|
|
379
|
+
#
|
|
380
|
+
# @option options [ true, false ] :allow_disk_use Set to true if disk
|
|
381
|
+
# usage is allowed during the aggregation.
|
|
382
|
+
# @option options [ Integer ] :batch_size The number of documents to return
|
|
383
|
+
# per batch.
|
|
384
|
+
# @option options [ true, false ] :bypass_document_validation Whether or
|
|
385
|
+
# not to skip document level validation.
|
|
386
|
+
# @option options [ Hash ] :collation The collation to use.
|
|
387
|
+
# @option options [ String ] :comment Associate a comment with the aggregation.
|
|
388
|
+
# @option options [ String ] :hint The index to use for the aggregation.
|
|
389
|
+
# @option options [ Integer ] :max_time_ms The maximum amount of time in
|
|
390
|
+
# milliseconds to allow the aggregation to run.
|
|
391
|
+
# @option options [ true, false ] :use_cursor Indicates whether the command
|
|
392
|
+
# will request that the server provide results using a cursor. Note that
|
|
393
|
+
# as of server version 3.6, aggregations always provide results using a
|
|
394
|
+
# cursor and this option is therefore not valid.
|
|
395
|
+
# @option options [ Session ] :session The session to use.
|
|
396
|
+
#
|
|
397
|
+
# @return [ Aggregation ] The aggregation object.
|
|
398
|
+
#
|
|
399
|
+
# @since 2.1.0
|
|
400
|
+
def aggregate(pipeline, options = {})
|
|
401
|
+
View.new(self, {}, options).aggregate(pipeline, options)
|
|
402
|
+
end
|
|
403
|
+
|
|
404
|
+
# As of version 3.6 of the MongoDB server, a ``$changeStream`` pipeline
|
|
405
|
+
# stage is supported in the aggregation framework. This stage allows users
|
|
406
|
+
# to request that notifications are sent for all changes to a particular
|
|
407
|
+
# collection.
|
|
408
|
+
#
|
|
409
|
+
# @example Get change notifications for a given collection.
|
|
410
|
+
# collection.watch([{ '$match' => { operationType: { '$in' => ['insert', 'replace'] } } }])
|
|
411
|
+
#
|
|
412
|
+
# @param [ Array<Hash> ] pipeline Optional additional filter operators.
|
|
413
|
+
# @param [ Hash ] options The change stream options.
|
|
414
|
+
#
|
|
415
|
+
# @option options [ String ] :full_document Allowed values: ‘default’,
|
|
416
|
+
# ‘updateLookup’. Defaults to ‘default’. When set to ‘updateLookup’,
|
|
417
|
+
# the change notification for partial updates will include both a delta
|
|
418
|
+
# describing the changes to the document, as well as a copy of the entire
|
|
419
|
+
# document that was changed from some time after the change occurred.
|
|
420
|
+
# @option options [ BSON::Document, Hash ] :resume_after Specifies the
|
|
421
|
+
# logical starting point for the new change stream.
|
|
422
|
+
# @option options [ Integer ] :max_await_time_ms The maximum amount of time
|
|
423
|
+
# for the server to wait on new documents to satisfy a change stream query.
|
|
424
|
+
# @option options [ Integer ] :batch_size The number of documents to return
|
|
425
|
+
# per batch.
|
|
426
|
+
# @option options [ BSON::Document, Hash ] :collation The collation to use.
|
|
427
|
+
# @option options [ Session ] :session The session to use.
|
|
428
|
+
# @option options [ BSON::Timestamp ] :start_at_operation_time Only return
|
|
429
|
+
# changes that occurred at or after the specified timestamp. Any command run
|
|
430
|
+
# against the server will return a cluster time that can be used here.
|
|
431
|
+
# Only recognized by server versions 4.0+.
|
|
432
|
+
#
|
|
433
|
+
# @note A change stream only allows 'majority' read concern.
|
|
434
|
+
# @note This helper method is preferable to running a raw aggregation with
|
|
435
|
+
# a $changeStream stage, for the purpose of supporting resumability.
|
|
436
|
+
#
|
|
437
|
+
# @return [ ChangeStream ] The change stream object.
|
|
438
|
+
#
|
|
439
|
+
# @since 2.5.0
|
|
440
|
+
def watch(pipeline = [], options = {})
|
|
441
|
+
View::ChangeStream.new(View.new(self, {}, options), pipeline, nil, options)
|
|
442
|
+
end
|
|
443
|
+
|
|
444
|
+
# Gets an estimated number of matching documents in the collection.
|
|
445
|
+
#
|
|
446
|
+
# @example Get the count.
|
|
447
|
+
# collection.count(name: 1)
|
|
448
|
+
#
|
|
449
|
+
# @param [ Hash ] filter A filter for matching documents.
|
|
450
|
+
# @param [ Hash ] options The count options.
|
|
451
|
+
#
|
|
452
|
+
# @option options [ Hash ] :hint The index to use.
|
|
453
|
+
# @option options [ Integer ] :limit The maximum number of documents to count.
|
|
454
|
+
# @option options [ Integer ] :max_time_ms The maximum amount of time to allow the command to run.
|
|
455
|
+
# @option options [ Integer ] :skip The number of documents to skip before counting.
|
|
456
|
+
# @option options [ Hash ] :read The read preference options.
|
|
457
|
+
# @option options [ Hash ] :collation The collation to use.
|
|
458
|
+
# @option options [ Session ] :session The session to use.
|
|
459
|
+
#
|
|
460
|
+
# @return [ Integer ] The document count.
|
|
461
|
+
#
|
|
462
|
+
# @since 2.1.0
|
|
463
|
+
#
|
|
464
|
+
# @deprecated Use #count_documents or estimated_document_count instead. However, note that the
|
|
465
|
+
# following operators will need to be substituted when switching to #count_documents:
|
|
466
|
+
# * $where should be replaced with $expr (only works on 3.6+)
|
|
467
|
+
# * $near should be replaced with $geoWithin with $center
|
|
468
|
+
# * $nearSphere should be replaced with $geoWithin with $centerSphere
|
|
469
|
+
def count(filter = nil, options = {})
|
|
470
|
+
View.new(self, filter || {}, options).count(options)
|
|
596
471
|
end
|
|
597
472
|
|
|
598
|
-
#
|
|
599
|
-
|
|
600
|
-
|
|
473
|
+
# Gets the number of documents matching the query. Unlike the deprecated
|
|
474
|
+
# #count method, this will return the exact number of documents matching
|
|
475
|
+
# the filter (or exact number of documents in the collection, if no filter
|
|
476
|
+
# is provided) rather than an estimate.
|
|
477
|
+
#
|
|
478
|
+
# Use #estimated_document_count to retrieve an estimate of the number
|
|
479
|
+
# of documents in the collection using the collection metadata.
|
|
480
|
+
#
|
|
481
|
+
# @param [ Hash ] filter A filter for matching documents.
|
|
482
|
+
# @param [ Hash ] options Options for the operation.
|
|
483
|
+
#
|
|
484
|
+
# @option options :skip [ Integer ] The number of documents to skip.
|
|
485
|
+
# @option options :hint [ Hash ] Override default index selection and force
|
|
486
|
+
# MongoDB to use a specific index for the query. Requires server version 3.6+.
|
|
487
|
+
# @option options :limit [ Integer ] Max number of docs to count.
|
|
488
|
+
# @option options :max_time_ms [ Integer ] The maximum amount of time to allow the
|
|
489
|
+
# command to run.
|
|
490
|
+
# @option options :read [ Hash ] The read preference options.
|
|
491
|
+
# @option options :collation [ Hash ] The collation to use.
|
|
492
|
+
#
|
|
493
|
+
# @return [ Integer ] The document count.
|
|
494
|
+
#
|
|
495
|
+
# @since 2.6.0
|
|
496
|
+
def count_documents(filter = {}, options = {})
|
|
497
|
+
View.new(self, filter, options).count_documents(options)
|
|
601
498
|
end
|
|
602
499
|
|
|
603
|
-
#
|
|
604
|
-
#
|
|
605
|
-
#
|
|
606
|
-
#
|
|
607
|
-
#
|
|
608
|
-
#
|
|
609
|
-
#
|
|
610
|
-
#
|
|
611
|
-
# @option opts
|
|
612
|
-
#
|
|
613
|
-
#
|
|
614
|
-
#
|
|
615
|
-
#
|
|
616
|
-
#
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
cmd.merge!(opts)
|
|
621
|
-
cmd[:sort] = Mongo::Support.format_order_clause(opts[:sort]) if opts[:sort]
|
|
622
|
-
|
|
623
|
-
@db.command(cmd)['value']
|
|
500
|
+
# Gets an estimate of the number of documents in the collection using the
|
|
501
|
+
# collection metadata.
|
|
502
|
+
#
|
|
503
|
+
# Use #count_documents to retrieve the exact number of documents in the
|
|
504
|
+
# collection, or to count documents matching a filter.
|
|
505
|
+
#
|
|
506
|
+
# @param [ Hash ] options Options for the operation.
|
|
507
|
+
#
|
|
508
|
+
# @option opts :max_time_ms [ Integer ] The maximum amount of time to allow
|
|
509
|
+
# the command to run for on the server.
|
|
510
|
+
# @option opts [ Hash ] :read The read preference options.
|
|
511
|
+
#
|
|
512
|
+
# @return [ Integer ] The document count.
|
|
513
|
+
#
|
|
514
|
+
# @since 2.6.0
|
|
515
|
+
def estimated_document_count(options = {})
|
|
516
|
+
View.new(self, {}, options).estimated_document_count(options)
|
|
624
517
|
end
|
|
625
518
|
|
|
626
|
-
#
|
|
627
|
-
# @note Aggregate requires server version >= 2.1.1
|
|
628
|
-
# @note Field References: Within an expression, field names must be quoted and prefixed by a dollar sign ($).
|
|
519
|
+
# Get a list of distinct values for a specific field.
|
|
629
520
|
#
|
|
630
|
-
# @example
|
|
631
|
-
#
|
|
521
|
+
# @example Get the distinct values.
|
|
522
|
+
# collection.distinct('name')
|
|
632
523
|
#
|
|
633
|
-
# @param [
|
|
524
|
+
# @param [ Symbol, String ] field_name The name of the field.
|
|
525
|
+
# @param [ Hash ] filter The documents from which to retrieve the distinct values.
|
|
526
|
+
# @param [ Hash ] options The distinct command options.
|
|
634
527
|
#
|
|
635
|
-
#
|
|
636
|
-
#
|
|
528
|
+
# @option options [ Integer ] :max_time_ms The maximum amount of time to allow the command to run.
|
|
529
|
+
# @option options [ Hash ] :read The read preference options.
|
|
530
|
+
# @option options [ Hash ] :collation The collation to use.
|
|
531
|
+
# @option options [ Session ] :session The session to use.
|
|
637
532
|
#
|
|
638
|
-
#
|
|
533
|
+
# @return [ Array<Object> ] The list of distinct values.
|
|
639
534
|
#
|
|
640
|
-
#
|
|
535
|
+
# @since 2.1.0
|
|
536
|
+
def distinct(field_name, filter = nil, options = {})
|
|
537
|
+
View.new(self, filter || {}, options).distinct(field_name, options)
|
|
538
|
+
end
|
|
539
|
+
|
|
540
|
+
# Get a view of all indexes for this collection. Can be iterated or has
|
|
541
|
+
# more operations.
|
|
641
542
|
#
|
|
642
|
-
#
|
|
543
|
+
# @example Get the index view.
|
|
544
|
+
# collection.indexes
|
|
643
545
|
#
|
|
644
|
-
#
|
|
546
|
+
# @param [ Hash ] options Options for getting a list of all indexes.
|
|
645
547
|
#
|
|
646
|
-
#
|
|
548
|
+
# @option options [ Session ] :session The session to use.
|
|
647
549
|
#
|
|
648
|
-
#
|
|
550
|
+
# @return [ View::Index ] The index view.
|
|
649
551
|
#
|
|
650
|
-
# @
|
|
651
|
-
|
|
652
|
-
|
|
552
|
+
# @since 2.0.0
|
|
553
|
+
def indexes(options = {})
|
|
554
|
+
Index::View.new(self, options)
|
|
555
|
+
end
|
|
556
|
+
|
|
557
|
+
# Get a pretty printed string inspection for the collection.
|
|
653
558
|
#
|
|
654
|
-
# @
|
|
559
|
+
# @example Inspect the collection.
|
|
560
|
+
# collection.inspect
|
|
655
561
|
#
|
|
656
|
-
# @
|
|
657
|
-
# @raise MongoOperationFailure if the aggregate command fails.
|
|
562
|
+
# @return [ String ] The collection inspection.
|
|
658
563
|
#
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
hash = BSON::OrderedHash.new
|
|
664
|
-
hash['aggregate'] = self.name
|
|
665
|
-
hash['pipeline'] = pipeline
|
|
666
|
-
|
|
667
|
-
result = @db.command(hash, command_options(opts))
|
|
668
|
-
unless Mongo::Support.ok?(result)
|
|
669
|
-
raise Mongo::OperationFailure, "aggregate failed: #{result['errmsg']}"
|
|
670
|
-
end
|
|
671
|
-
|
|
672
|
-
return result["result"]
|
|
564
|
+
# @since 2.0.0
|
|
565
|
+
def inspect
|
|
566
|
+
"#<Mongo::Collection:0x#{object_id} namespace=#{namespace}>"
|
|
673
567
|
end
|
|
674
568
|
|
|
675
|
-
#
|
|
676
|
-
#
|
|
677
|
-
# @
|
|
678
|
-
#
|
|
679
|
-
#
|
|
680
|
-
# @
|
|
681
|
-
#
|
|
682
|
-
#
|
|
683
|
-
#
|
|
684
|
-
#
|
|
685
|
-
# @
|
|
686
|
-
#
|
|
687
|
-
# @
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
# @option opts [Boolean] :keeptemp (false) if true, the generated collection will be persisted. The default
|
|
691
|
-
# is false. Note that this option has no effect is versions of MongoDB > v1.7.6.
|
|
692
|
-
# @option opts [Boolean ] :verbose (false) if true, provides statistics on job execution time.
|
|
693
|
-
# @option opts [Boolean] :raw (false) if true, return the raw result object from the map_reduce command, and not
|
|
694
|
-
# the instantiated collection that's returned by default. Note if a collection name isn't returned in the
|
|
695
|
-
# map-reduce output (as, for example, when using :out => { :inline => 1 }), then you must specify this option
|
|
696
|
-
# or an ArgumentError will be raised.
|
|
697
|
-
# @option opts [:primary, :secondary] :read Read preference indicating which server to run this map-reduce
|
|
698
|
-
# on. See Collection#find for more details.
|
|
699
|
-
# @option opts [String] :comment (nil) a comment to include in profiling logs
|
|
700
|
-
#
|
|
701
|
-
# @return [Collection, Hash] a Mongo::Collection object or a Hash with the map-reduce command's results.
|
|
702
|
-
#
|
|
703
|
-
# @raise ArgumentError if you specify { :out => { :inline => true }} but don't specify :raw => true.
|
|
704
|
-
#
|
|
705
|
-
# @see http://www.mongodb.org/display/DOCS/MapReduce Offical MongoDB map/reduce documentation.
|
|
706
|
-
#
|
|
707
|
-
# @core mapreduce map_reduce-instance_method
|
|
708
|
-
def map_reduce(map, reduce, opts={})
|
|
709
|
-
map = BSON::Code.new(map) unless map.is_a?(BSON::Code)
|
|
710
|
-
reduce = BSON::Code.new(reduce) unless reduce.is_a?(BSON::Code)
|
|
711
|
-
raw = opts.delete(:raw)
|
|
712
|
-
|
|
713
|
-
hash = BSON::OrderedHash.new
|
|
714
|
-
hash['mapreduce'] = self.name
|
|
715
|
-
hash['map'] = map
|
|
716
|
-
hash['reduce'] = reduce
|
|
717
|
-
hash.merge! opts
|
|
718
|
-
if hash[:sort]
|
|
719
|
-
hash[:sort] = Mongo::Support.format_order_clause(hash[:sort])
|
|
720
|
-
end
|
|
721
|
-
|
|
722
|
-
result = @db.command(hash, command_options(opts))
|
|
723
|
-
unless Mongo::Support.ok?(result)
|
|
724
|
-
raise Mongo::OperationFailure, "map-reduce failed: #{result['errmsg']}"
|
|
725
|
-
end
|
|
569
|
+
# Insert a single document into the collection.
|
|
570
|
+
#
|
|
571
|
+
# @example Insert a document into the collection.
|
|
572
|
+
# collection.insert_one({ name: 'test' })
|
|
573
|
+
#
|
|
574
|
+
# @param [ Hash ] document The document to insert.
|
|
575
|
+
# @param [ Hash ] opts The insert options.
|
|
576
|
+
#
|
|
577
|
+
# @option opts [ Session ] :session The session to use for the operation.
|
|
578
|
+
#
|
|
579
|
+
# @return [ Result ] The database response wrapper.
|
|
580
|
+
#
|
|
581
|
+
# @since 2.0.0
|
|
582
|
+
def insert_one(document, opts = {})
|
|
583
|
+
QueryCache.clear_namespace(namespace)
|
|
726
584
|
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
if result['result'].is_a? BSON::OrderedHash and result['result'].has_key? 'db' and result['result'].has_key? 'collection'
|
|
731
|
-
otherdb = @db.connection[result['result']['db']]
|
|
732
|
-
otherdb[result['result']['collection']]
|
|
585
|
+
client.send(:with_session, opts) do |session|
|
|
586
|
+
write_concern = if opts[:write_concern]
|
|
587
|
+
WriteConcern.get(opts[:write_concern])
|
|
733
588
|
else
|
|
734
|
-
|
|
589
|
+
write_concern_with_session(session)
|
|
735
590
|
end
|
|
736
|
-
else
|
|
737
|
-
raise ArgumentError, "Could not instantiate collection from result. If you specified " +
|
|
738
|
-
"{:out => {:inline => true}}, then you must also specify :raw => true to get the results."
|
|
739
|
-
end
|
|
740
|
-
end
|
|
741
|
-
alias :mapreduce :map_reduce
|
|
742
|
-
|
|
743
|
-
# Perform a group aggregation.
|
|
744
|
-
#
|
|
745
|
-
# @param [Hash] opts the options for this group operation. The minimum required are :initial
|
|
746
|
-
# and :reduce.
|
|
747
|
-
#
|
|
748
|
-
# @option opts [Array, String, Symbol] :key (nil) Either the name of a field or a list of fields to group by (optional).
|
|
749
|
-
# @option opts [String, BSON::Code] :keyf (nil) A JavaScript function to be used to generate the grouping keys (optional).
|
|
750
|
-
# @option opts [String, BSON::Code] :cond ({}) A document specifying a query for filtering the documents over
|
|
751
|
-
# which the aggregation is run (optional).
|
|
752
|
-
# @option opts [Hash] :initial the initial value of the aggregation counter object (required).
|
|
753
|
-
# @option opts [String, BSON::Code] :reduce (nil) a JavaScript aggregation function (required).
|
|
754
|
-
# @option opts [String, BSON::Code] :finalize (nil) a JavaScript function that receives and modifies
|
|
755
|
-
# each of the resultant grouped objects. Available only when group is run with command
|
|
756
|
-
# set to true.
|
|
757
|
-
# @option opts [:primary, :secondary] :read Read preference indicating which server to perform this group
|
|
758
|
-
# on. See Collection#find for more details.
|
|
759
|
-
# @option opts [String] :comment (nil) a comment to include in profiling logs
|
|
760
|
-
#
|
|
761
|
-
# @return [Array] the command response consisting of grouped items.
|
|
762
|
-
def group(opts, condition={}, initial={}, reduce=nil, finalize=nil)
|
|
763
|
-
if opts.is_a?(Hash)
|
|
764
|
-
return new_group(opts)
|
|
765
|
-
else
|
|
766
|
-
warn "Collection#group no longer take a list of parameters. This usage is deprecated and will be remove in v2.0." +
|
|
767
|
-
"Check out the new API at http://api.mongodb.org/ruby/current/Mongo/Collection.html#group-instance_method"
|
|
768
|
-
end
|
|
769
|
-
|
|
770
|
-
reduce = BSON::Code.new(reduce) unless reduce.is_a?(BSON::Code)
|
|
771
|
-
|
|
772
|
-
group_command = {
|
|
773
|
-
"group" => {
|
|
774
|
-
"ns" => @name,
|
|
775
|
-
"$reduce" => reduce,
|
|
776
|
-
"cond" => condition,
|
|
777
|
-
"initial" => initial
|
|
778
|
-
}
|
|
779
|
-
}
|
|
780
|
-
|
|
781
|
-
if opts.is_a?(Symbol)
|
|
782
|
-
raise MongoArgumentError, "Group takes either an array of fields to group by or a JavaScript function" +
|
|
783
|
-
"in the form of a String or BSON::Code."
|
|
784
|
-
end
|
|
785
591
|
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
key_type = "key"
|
|
789
|
-
key_value = {}
|
|
790
|
-
opts.each { |k| key_value[k] = 1 }
|
|
791
|
-
else
|
|
792
|
-
key_type = "$keyf"
|
|
793
|
-
key_value = opts.is_a?(BSON::Code) ? opts : BSON::Code.new(opts)
|
|
592
|
+
if document.nil?
|
|
593
|
+
raise ArgumentError, "Document to be inserted cannot be nil"
|
|
794
594
|
end
|
|
795
595
|
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
else
|
|
809
|
-
raise OperationFailure, "group command failed: #{result['errmsg']}"
|
|
810
|
-
end
|
|
811
|
-
end
|
|
812
|
-
|
|
813
|
-
private
|
|
814
|
-
|
|
815
|
-
def new_group(opts={})
|
|
816
|
-
reduce = opts[:reduce]
|
|
817
|
-
finalize = opts[:finalize]
|
|
818
|
-
cond = opts.fetch(:cond, {})
|
|
819
|
-
initial = opts[:initial]
|
|
820
|
-
|
|
821
|
-
if !(reduce && initial)
|
|
822
|
-
raise MongoArgumentError, "Group requires at minimum values for initial and reduce."
|
|
823
|
-
end
|
|
824
|
-
|
|
825
|
-
cmd = {
|
|
826
|
-
"group" => {
|
|
827
|
-
"ns" => @name,
|
|
828
|
-
"$reduce" => reduce.to_bson_code,
|
|
829
|
-
"cond" => cond,
|
|
830
|
-
"initial" => initial
|
|
831
|
-
}
|
|
832
|
-
}
|
|
833
|
-
|
|
834
|
-
if finalize
|
|
835
|
-
cmd['group']['finalize'] = finalize.to_bson_code
|
|
836
|
-
end
|
|
837
|
-
|
|
838
|
-
if key = opts[:key]
|
|
839
|
-
if key.is_a?(String) || key.is_a?(Symbol)
|
|
840
|
-
key = [key]
|
|
596
|
+
write_with_retry(session, write_concern) do |server, txn_num|
|
|
597
|
+
Operation::Insert.new(
|
|
598
|
+
:documents => [ document ],
|
|
599
|
+
:db_name => database.name,
|
|
600
|
+
:coll_name => name,
|
|
601
|
+
:write_concern => write_concern,
|
|
602
|
+
:bypass_document_validation => !!opts[:bypass_document_validation],
|
|
603
|
+
:options => opts,
|
|
604
|
+
:id_generator => client.options[:id_generator],
|
|
605
|
+
:session => session,
|
|
606
|
+
:txn_num => txn_num,
|
|
607
|
+
).execute(server, context: Operation::Context.new(client: client, session: session))
|
|
841
608
|
end
|
|
842
|
-
key_value = {}
|
|
843
|
-
key.each { |k| key_value[k] = 1 }
|
|
844
|
-
cmd["group"]["key"] = key_value
|
|
845
|
-
elsif keyf = opts[:keyf]
|
|
846
|
-
cmd["group"]["$keyf"] = keyf.to_bson_code
|
|
847
609
|
end
|
|
848
|
-
|
|
849
|
-
result = @db.command(cmd, command_options(opts))
|
|
850
|
-
result["retval"]
|
|
851
|
-
end
|
|
852
|
-
|
|
853
|
-
public
|
|
854
|
-
|
|
855
|
-
# Return a list of distinct values for +key+ across all
|
|
856
|
-
# documents in the collection. The key may use dot notation
|
|
857
|
-
# to reach into an embedded object.
|
|
858
|
-
#
|
|
859
|
-
# @param [String, Symbol, OrderedHash] key or hash to group by.
|
|
860
|
-
# @param [Hash] query a selector for limiting the result set over which to group.
|
|
861
|
-
# @param [Hash] opts the options for this distinct operation.
|
|
862
|
-
#
|
|
863
|
-
# @option opts [:primary, :secondary] :read Read preference indicating which server to perform this query
|
|
864
|
-
# on. See Collection#find for more details.
|
|
865
|
-
# @option opts [String] :comment (nil) a comment to include in profiling logs
|
|
866
|
-
#
|
|
867
|
-
# @example Saving zip codes and ages and returning distinct results.
|
|
868
|
-
# @collection.save({:zip => 10010, :name => {:age => 27}})
|
|
869
|
-
# @collection.save({:zip => 94108, :name => {:age => 24}})
|
|
870
|
-
# @collection.save({:zip => 10010, :name => {:age => 27}})
|
|
871
|
-
# @collection.save({:zip => 99701, :name => {:age => 24}})
|
|
872
|
-
# @collection.save({:zip => 94108, :name => {:age => 27}})
|
|
873
|
-
#
|
|
874
|
-
# @collection.distinct(:zip)
|
|
875
|
-
# [10010, 94108, 99701]
|
|
876
|
-
# @collection.distinct("name.age")
|
|
877
|
-
# [27, 24]
|
|
878
|
-
#
|
|
879
|
-
# # You may also pass a document selector as the second parameter
|
|
880
|
-
# # to limit the documents over which distinct is run:
|
|
881
|
-
# @collection.distinct("name.age", {"name.age" => {"$gt" => 24}})
|
|
882
|
-
# [27]
|
|
883
|
-
#
|
|
884
|
-
# @return [Array] an array of distinct values.
|
|
885
|
-
def distinct(key, query=nil, opts={})
|
|
886
|
-
raise MongoArgumentError unless [String, Symbol].include?(key.class)
|
|
887
|
-
command = BSON::OrderedHash.new
|
|
888
|
-
command[:distinct] = @name
|
|
889
|
-
command[:key] = key.to_s
|
|
890
|
-
command[:query] = query
|
|
891
|
-
|
|
892
|
-
@db.command(command, command_options(opts))["values"]
|
|
893
610
|
end
|
|
894
611
|
|
|
895
|
-
#
|
|
612
|
+
# Insert the provided documents into the collection.
|
|
896
613
|
#
|
|
897
|
-
#
|
|
898
|
-
#
|
|
614
|
+
# @example Insert documents into the collection.
|
|
615
|
+
# collection.insert_many([{ name: 'test' }])
|
|
899
616
|
#
|
|
900
|
-
# @param [
|
|
617
|
+
# @param [ Array<Hash> ] documents The documents to insert.
|
|
618
|
+
# @param [ Hash ] options The insert options.
|
|
901
619
|
#
|
|
902
|
-
# @
|
|
620
|
+
# @option options [ true | false ] :ordered Whether the operations
|
|
621
|
+
# should be executed in order.
|
|
622
|
+
# @option options [ Session ] :session The session to use for the operation.
|
|
903
623
|
#
|
|
904
|
-
# @
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
raise TypeError, "new_name must be a string or symbol"
|
|
910
|
-
end
|
|
911
|
-
|
|
912
|
-
new_name = new_name.to_s
|
|
913
|
-
|
|
914
|
-
if new_name.empty? or new_name.include? ".."
|
|
915
|
-
raise Mongo::InvalidNSName, "collection names cannot be empty"
|
|
916
|
-
end
|
|
917
|
-
if new_name.include? "$"
|
|
918
|
-
raise Mongo::InvalidNSName, "collection names must not contain '$'"
|
|
919
|
-
end
|
|
920
|
-
if new_name.match(/^\./) or new_name.match(/\.$/)
|
|
921
|
-
raise Mongo::InvalidNSName, "collection names must not start or end with '.'"
|
|
922
|
-
end
|
|
624
|
+
# @return [ Result ] The database response wrapper.
|
|
625
|
+
#
|
|
626
|
+
# @since 2.0.0
|
|
627
|
+
def insert_many(documents, options = {})
|
|
628
|
+
QueryCache.clear_namespace(namespace)
|
|
923
629
|
|
|
924
|
-
|
|
925
|
-
|
|
630
|
+
inserts = documents.map{ |doc| { :insert_one => doc }}
|
|
631
|
+
bulk_write(inserts, options)
|
|
926
632
|
end
|
|
927
633
|
|
|
928
|
-
#
|
|
634
|
+
# Execute a batch of bulk write operations.
|
|
929
635
|
#
|
|
930
|
-
# @
|
|
636
|
+
# @example Execute a bulk write.
|
|
637
|
+
# collection.bulk_write(operations, options)
|
|
931
638
|
#
|
|
932
|
-
# @
|
|
933
|
-
|
|
934
|
-
|
|
639
|
+
# @param [ Array<Hash> ] requests The bulk write requests.
|
|
640
|
+
# @param [ Hash ] options The options.
|
|
641
|
+
#
|
|
642
|
+
# @option options [ true, false ] :ordered Whether the operations
|
|
643
|
+
# should be executed in order.
|
|
644
|
+
# @option options [ Hash ] :write_concern The write concern options.
|
|
645
|
+
# Can be :w => Integer, :fsync => Boolean, :j => Boolean.
|
|
646
|
+
# @option options [ true, false ] :bypass_document_validation Whether or
|
|
647
|
+
# not to skip document level validation.
|
|
648
|
+
# @option options [ Session ] :session The session to use for the set of operations.
|
|
649
|
+
#
|
|
650
|
+
# @return [ BulkWrite::Result ] The result of the operation.
|
|
651
|
+
#
|
|
652
|
+
# @since 2.0.0
|
|
653
|
+
def bulk_write(requests, options = {})
|
|
654
|
+
BulkWrite.new(self, requests, options).execute
|
|
935
655
|
end
|
|
936
656
|
|
|
937
|
-
#
|
|
938
|
-
#
|
|
657
|
+
# Remove a document from the collection.
|
|
658
|
+
#
|
|
659
|
+
# @example Remove a single document from the collection.
|
|
660
|
+
# collection.delete_one
|
|
939
661
|
#
|
|
940
|
-
# @
|
|
941
|
-
|
|
942
|
-
|
|
662
|
+
# @param [ Hash ] filter The filter to use.
|
|
663
|
+
# @param [ Hash ] options The options.
|
|
664
|
+
#
|
|
665
|
+
# @option options [ Hash ] :collation The collation to use.
|
|
666
|
+
# @option options [ Session ] :session The session to use.
|
|
667
|
+
# @option options [ Hash | String ] :hint The index to use for this operation.
|
|
668
|
+
# May be specified as a Hash (e.g. { _id: 1 }) or a String (e.g. "_id_").
|
|
669
|
+
#
|
|
670
|
+
# @return [ Result ] The response from the database.
|
|
671
|
+
#
|
|
672
|
+
# @since 2.1.0
|
|
673
|
+
def delete_one(filter = nil, options = {})
|
|
674
|
+
find(filter, options).delete_one(options)
|
|
943
675
|
end
|
|
944
676
|
|
|
945
|
-
#
|
|
677
|
+
# Remove documents from the collection.
|
|
678
|
+
#
|
|
679
|
+
# @example Remove multiple documents from the collection.
|
|
680
|
+
# collection.delete_many
|
|
946
681
|
#
|
|
947
|
-
# @
|
|
948
|
-
|
|
949
|
-
|
|
682
|
+
# @param [ Hash ] filter The filter to use.
|
|
683
|
+
# @param [ Hash ] options The options.
|
|
684
|
+
#
|
|
685
|
+
# @option options [ Hash ] :collation The collation to use.
|
|
686
|
+
# @option options [ Session ] :session The session to use.
|
|
687
|
+
# @option options [ Hash | String ] :hint The index to use for this operation.
|
|
688
|
+
# May be specified as a Hash (e.g. { _id: 1 }) or a String (e.g. "_id_").
|
|
689
|
+
#
|
|
690
|
+
# @return [ Result ] The response from the database.
|
|
691
|
+
#
|
|
692
|
+
# @since 2.1.0
|
|
693
|
+
def delete_many(filter = nil, options = {})
|
|
694
|
+
find(filter, options).delete_many(options)
|
|
950
695
|
end
|
|
951
696
|
|
|
952
|
-
#
|
|
953
|
-
#
|
|
954
|
-
#
|
|
955
|
-
#
|
|
956
|
-
#
|
|
957
|
-
#
|
|
958
|
-
#
|
|
959
|
-
#
|
|
960
|
-
#
|
|
961
|
-
# @
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
697
|
+
# Execute a parallel scan on the collection view.
|
|
698
|
+
#
|
|
699
|
+
# Returns a list of up to cursor_count cursors that can be iterated concurrently.
|
|
700
|
+
# As long as the collection is not modified during scanning, each document appears once
|
|
701
|
+
# in one of the cursors' result sets.
|
|
702
|
+
#
|
|
703
|
+
# @example Execute a parallel collection scan.
|
|
704
|
+
# collection.parallel_scan(2)
|
|
705
|
+
#
|
|
706
|
+
# @param [ Integer ] cursor_count The max number of cursors to return.
|
|
707
|
+
# @param [ Hash ] options The parallel scan command options.
|
|
708
|
+
#
|
|
709
|
+
# @option options [ Integer ] :max_time_ms The maximum amount of time to allow the command
|
|
710
|
+
# to run in milliseconds.
|
|
711
|
+
# @option options [ Session ] :session The session to use.
|
|
712
|
+
#
|
|
713
|
+
# @return [ Array<Cursor> ] An array of cursors.
|
|
714
|
+
#
|
|
715
|
+
# @since 2.1
|
|
716
|
+
def parallel_scan(cursor_count, options = {})
|
|
717
|
+
find({}, options).send(:parallel_scan, cursor_count, options)
|
|
968
718
|
end
|
|
969
719
|
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
#
|
|
975
|
-
#
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
720
|
+
# Replaces a single document in the collection with the new document.
|
|
721
|
+
#
|
|
722
|
+
# @example Replace a single document.
|
|
723
|
+
# collection.replace_one({ name: 'test' }, { name: 'test1' })
|
|
724
|
+
#
|
|
725
|
+
# @param [ Hash ] filter The filter to use.
|
|
726
|
+
# @param [ Hash ] replacement The replacement document..
|
|
727
|
+
# @param [ Hash ] options The options.
|
|
728
|
+
#
|
|
729
|
+
# @option options [ true, false ] :upsert Whether to upsert if the
|
|
730
|
+
# document doesn't exist.
|
|
731
|
+
# @option options [ true, false ] :bypass_document_validation Whether or
|
|
732
|
+
# not to skip document level validation.
|
|
733
|
+
# @option options [ Hash ] :collation The collation to use.
|
|
734
|
+
# @option options [ Session ] :session The session to use.
|
|
735
|
+
# @option options [ Hash | String ] :hint The index to use for this operation.
|
|
736
|
+
# May be specified as a Hash (e.g. { _id: 1 }) or a String (e.g. "_id_").
|
|
737
|
+
#
|
|
738
|
+
# @return [ Result ] The response from the database.
|
|
739
|
+
#
|
|
740
|
+
# @since 2.1.0
|
|
741
|
+
def replace_one(filter, replacement, options = {})
|
|
742
|
+
find(filter, options).replace_one(replacement, options)
|
|
987
743
|
end
|
|
988
744
|
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
745
|
+
# Update documents in the collection.
|
|
746
|
+
#
|
|
747
|
+
# @example Update multiple documents in the collection.
|
|
748
|
+
# collection.update_many({ name: 'test'}, '$set' => { name: 'test1' })
|
|
749
|
+
#
|
|
750
|
+
# @param [ Hash ] filter The filter to use.
|
|
751
|
+
# @param [ Hash | Array<Hash> ] update The update document or pipeline.
|
|
752
|
+
# @param [ Hash ] options The options.
|
|
753
|
+
#
|
|
754
|
+
# @option options [ true, false ] :upsert Whether to upsert if the
|
|
755
|
+
# document doesn't exist.
|
|
756
|
+
# @option options [ true, false ] :bypass_document_validation Whether or
|
|
757
|
+
# not to skip document level validation.
|
|
758
|
+
# @option options [ Hash ] :collation The collation to use.
|
|
759
|
+
# @option options [ Array ] :array_filters A set of filters specifying to which array elements
|
|
760
|
+
# an update should apply.
|
|
761
|
+
# @option options [ Session ] :session The session to use.
|
|
762
|
+
# @option options [ Hash | String ] :hint The index to use for this operation.
|
|
763
|
+
# May be specified as a Hash (e.g. { _id: 1 }) or a String (e.g. "_id_").
|
|
764
|
+
#
|
|
765
|
+
# @return [ Result ] The response from the database.
|
|
766
|
+
#
|
|
767
|
+
# @since 2.1.0
|
|
768
|
+
def update_many(filter, update, options = {})
|
|
769
|
+
find(filter, options).update_many(update, options)
|
|
1002
770
|
end
|
|
1003
771
|
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
772
|
+
# Update a single document in the collection.
|
|
773
|
+
#
|
|
774
|
+
# @example Update a single document in the collection.
|
|
775
|
+
# collection.update_one({ name: 'test'}, '$set' => { name: 'test1'})
|
|
776
|
+
#
|
|
777
|
+
# @param [ Hash ] filter The filter to use.
|
|
778
|
+
# @param [ Hash | Array<Hash> ] update The update document or pipeline.
|
|
779
|
+
# @param [ Hash ] options The options.
|
|
780
|
+
#
|
|
781
|
+
# @option options [ true, false ] :upsert Whether to upsert if the
|
|
782
|
+
# document doesn't exist.
|
|
783
|
+
# @option options [ true, false ] :bypass_document_validation Whether or
|
|
784
|
+
# not to skip document level validation.
|
|
785
|
+
# @option options [ Hash ] :collation The collation to use.
|
|
786
|
+
# @option options [ Array ] :array_filters A set of filters specifying to which array elements
|
|
787
|
+
# an update should apply.
|
|
788
|
+
# @option options [ Session ] :session The session to use.
|
|
789
|
+
# @option options [ Hash | String ] :hint The index to use for this operation.
|
|
790
|
+
# May be specified as a Hash (e.g. { _id: 1 }) or a String (e.g. "_id_").
|
|
791
|
+
#
|
|
792
|
+
# @return [ Result ] The response from the database.
|
|
793
|
+
#
|
|
794
|
+
# @since 2.1.0
|
|
795
|
+
def update_one(filter, update, options = {})
|
|
796
|
+
find(filter, options).update_one(update, options)
|
|
1012
797
|
end
|
|
1013
798
|
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
799
|
+
# Finds a single document in the database via findAndModify and deletes
|
|
800
|
+
# it, returning the original document.
|
|
801
|
+
#
|
|
802
|
+
# @example Find one document and delete it.
|
|
803
|
+
# collection.find_one_and_delete(name: 'test')
|
|
804
|
+
#
|
|
805
|
+
# @param [ Hash ] filter The filter to use.
|
|
806
|
+
# @param [ Hash ] options The options.
|
|
807
|
+
#
|
|
808
|
+
# @option options [ Integer ] :max_time_ms The maximum amount of time to allow the command
|
|
809
|
+
# to run in milliseconds.
|
|
810
|
+
# @option options [ Hash ] :projection The fields to include or exclude in the returned doc.
|
|
811
|
+
# @option options [ Hash ] :sort The key and direction pairs by which the result set
|
|
812
|
+
# will be sorted.
|
|
813
|
+
# @option options [ Hash ] :write_concern The write concern options.
|
|
814
|
+
# Defaults to the collection's write concern.
|
|
815
|
+
# @option options [ Hash ] :collation The collation to use.
|
|
816
|
+
# @option options [ Session ] :session The session to use.
|
|
817
|
+
# @option options [ Hash | String ] :hint The index to use for this operation.
|
|
818
|
+
# May be specified as a Hash (e.g. { _id: 1 }) or a String (e.g. "_id_").
|
|
819
|
+
#
|
|
820
|
+
# @return [ BSON::Document, nil ] The document, if found.
|
|
821
|
+
#
|
|
822
|
+
# @since 2.1.0
|
|
823
|
+
def find_one_and_delete(filter, options = {})
|
|
824
|
+
find(filter, options).find_one_and_delete(options)
|
|
1034
825
|
end
|
|
1035
826
|
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
827
|
+
# Finds a single document via findAndModify and updates it, returning the original doc unless
|
|
828
|
+
# otherwise specified.
|
|
829
|
+
#
|
|
830
|
+
# @example Find a document and update it, returning the original.
|
|
831
|
+
# collection.find_one_and_update({ name: 'test' }, { "$set" => { name: 'test1' }})
|
|
832
|
+
#
|
|
833
|
+
# @example Find a document and update it, returning the updated document.
|
|
834
|
+
# collection.find_one_and_update({ name: 'test' }, { "$set" => { name: 'test1' }}, :return_document => :after)
|
|
835
|
+
#
|
|
836
|
+
# @param [ Hash ] filter The filter to use.
|
|
837
|
+
# @param [ Hash | Array<Hash> ] update The update document or pipeline.
|
|
838
|
+
# @param [ Hash ] options The options.
|
|
839
|
+
#
|
|
840
|
+
# @option options [ Integer ] :max_time_ms The maximum amount of time to allow the command
|
|
841
|
+
# to run in milliseconds.
|
|
842
|
+
# @option options [ Hash ] :projection The fields to include or exclude in the returned doc.
|
|
843
|
+
# @option options [ Hash ] :sort The key and direction pairs by which the result set
|
|
844
|
+
# will be sorted.
|
|
845
|
+
# @option options [ Symbol ] :return_document Either :before or :after.
|
|
846
|
+
# @option options [ true, false ] :upsert Whether to upsert if the document doesn't exist.
|
|
847
|
+
# @option options [ true, false ] :bypass_document_validation Whether or
|
|
848
|
+
# not to skip document level validation.
|
|
849
|
+
# @option options [ Hash ] :write_concern The write concern options.
|
|
850
|
+
# Defaults to the collection's write concern.
|
|
851
|
+
# @option options [ Hash ] :collation The collation to use.
|
|
852
|
+
# @option options [ Array ] :array_filters A set of filters specifying to which array elements
|
|
853
|
+
# an update should apply.
|
|
854
|
+
# @option options [ Session ] :session The session to use.
|
|
855
|
+
# @option options [ Hash | String ] :hint The index to use for this operation.
|
|
856
|
+
# May be specified as a Hash (e.g. { _id: 1 }) or a String (e.g. "_id_").
|
|
857
|
+
#
|
|
858
|
+
# @return [ BSON::Document ] The document.
|
|
859
|
+
#
|
|
860
|
+
# @since 2.1.0
|
|
861
|
+
def find_one_and_update(filter, update, options = {})
|
|
862
|
+
find(filter, options).find_one_and_update(update, options)
|
|
1044
863
|
end
|
|
1045
864
|
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
865
|
+
# Finds a single document and replaces it, returning the original doc unless
|
|
866
|
+
# otherwise specified.
|
|
867
|
+
#
|
|
868
|
+
# @example Find a document and replace it, returning the original.
|
|
869
|
+
# collection.find_one_and_replace({ name: 'test' }, { name: 'test1' })
|
|
870
|
+
#
|
|
871
|
+
# @example Find a document and replace it, returning the new document.
|
|
872
|
+
# collection.find_one_and_replace({ name: 'test' }, { name: 'test1' }, :return_document => :after)
|
|
873
|
+
#
|
|
874
|
+
# @param [ Hash ] filter The filter to use.
|
|
875
|
+
# @param [ BSON::Document ] replacement The replacement document.
|
|
876
|
+
# @param [ Hash ] options The options.
|
|
877
|
+
#
|
|
878
|
+
# @option options [ Integer ] :max_time_ms The maximum amount of time to allow the command
|
|
879
|
+
# to run in milliseconds.
|
|
880
|
+
# @option options [ Hash ] :projection The fields to include or exclude in the returned doc.
|
|
881
|
+
# @option options [ Hash ] :sort The key and direction pairs by which the result set
|
|
882
|
+
# will be sorted.
|
|
883
|
+
# @option options [ Symbol ] :return_document Either :before or :after.
|
|
884
|
+
# @option options [ true, false ] :upsert Whether to upsert if the document doesn't exist.
|
|
885
|
+
# @option options [ true, false ] :bypass_document_validation Whether or
|
|
886
|
+
# not to skip document level validation.
|
|
887
|
+
# @option options [ Hash ] :write_concern The write concern options.
|
|
888
|
+
# Defaults to the collection's write concern.
|
|
889
|
+
# @option options [ Hash ] :collation The collation to use.
|
|
890
|
+
# @option options [ Session ] :session The session to use.
|
|
891
|
+
# @option options [ Hash | String ] :hint The index to use for this operation.
|
|
892
|
+
# May be specified as a Hash (e.g. { _id: 1 }) or a String (e.g. "_id_").
|
|
893
|
+
#
|
|
894
|
+
# @return [ BSON::Document ] The document.
|
|
895
|
+
#
|
|
896
|
+
# @since 2.1.0
|
|
897
|
+
def find_one_and_replace(filter, replacement, options = {})
|
|
898
|
+
find(filter, options).find_one_and_update(replacement, options)
|
|
1067
899
|
end
|
|
1068
900
|
|
|
1069
|
-
#
|
|
1070
|
-
#
|
|
1071
|
-
#
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
collect_on_error = !!flags[:collect_on_error]
|
|
1081
|
-
error_docs = [] if collect_on_error
|
|
1082
|
-
|
|
1083
|
-
BSON::BSON_RUBY.serialize_cstr(message, "#{@db.name}.#{collection_name}")
|
|
1084
|
-
documents =
|
|
1085
|
-
if collect_on_error
|
|
1086
|
-
documents.select do |doc|
|
|
1087
|
-
begin
|
|
1088
|
-
message.put_binary(BSON::BSON_CODER.serialize(doc, check_keys, true, @connection.max_bson_size).to_s)
|
|
1089
|
-
true
|
|
1090
|
-
rescue StandardError # StandardError will be replaced with BSONError
|
|
1091
|
-
doc.delete(:_id)
|
|
1092
|
-
error_docs << doc
|
|
1093
|
-
false
|
|
1094
|
-
end
|
|
1095
|
-
end
|
|
1096
|
-
else
|
|
1097
|
-
documents.each do |doc|
|
|
1098
|
-
message.put_binary(BSON::BSON_CODER.serialize(doc, check_keys, true, @connection.max_bson_size).to_s)
|
|
1099
|
-
end
|
|
1100
|
-
end
|
|
1101
|
-
|
|
1102
|
-
if message.size > @connection.max_message_size
|
|
1103
|
-
raise InvalidOperation, "Exceded maximum insert size of #{@connection.max_message_size} bytes"
|
|
1104
|
-
end
|
|
1105
|
-
|
|
1106
|
-
instrument(:insert, :database => @db.name, :collection => collection_name, :documents => documents) do
|
|
1107
|
-
if Mongo::WriteConcern.gle?(write_concern)
|
|
1108
|
-
@connection.send_message_with_gle(Mongo::Constants::OP_INSERT, message, @db.name, nil, write_concern)
|
|
1109
|
-
else
|
|
1110
|
-
@connection.send_message(Mongo::Constants::OP_INSERT, message)
|
|
1111
|
-
end
|
|
1112
|
-
end
|
|
1113
|
-
|
|
1114
|
-
doc_ids = documents.collect { |o| o[:_id] || o['_id'] }
|
|
1115
|
-
if collect_on_error
|
|
1116
|
-
return doc_ids, error_docs
|
|
1117
|
-
else
|
|
1118
|
-
doc_ids
|
|
1119
|
-
end
|
|
901
|
+
# Get the fully qualified namespace of the collection.
|
|
902
|
+
#
|
|
903
|
+
# @example Get the fully qualified namespace.
|
|
904
|
+
# collection.namespace
|
|
905
|
+
#
|
|
906
|
+
# @return [ String ] The collection namespace.
|
|
907
|
+
#
|
|
908
|
+
# @since 2.0.0
|
|
909
|
+
def namespace
|
|
910
|
+
"#{database.name}.#{name}"
|
|
1120
911
|
end
|
|
1121
912
|
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
913
|
+
# Whether the collection is a system collection.
|
|
914
|
+
#
|
|
915
|
+
# @return [ Boolean ] Whether the system is a system collection.
|
|
916
|
+
#
|
|
917
|
+
# @api private
|
|
918
|
+
def system_collection?
|
|
919
|
+
name.start_with?('system.')
|
|
1128
920
|
end
|
|
1129
921
|
end
|
|
1130
|
-
|
|
1131
922
|
end
|