mongo 2.13.1 → 2.14.0.rc1
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 +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +1 -4
- data/lib/mongo.rb +9 -0
- data/lib/mongo/address/ipv4.rb +1 -1
- data/lib/mongo/address/ipv6.rb +1 -1
- data/lib/mongo/bulk_write.rb +17 -0
- data/lib/mongo/caching_cursor.rb +74 -0
- data/lib/mongo/client.rb +47 -8
- data/lib/mongo/cluster.rb +3 -3
- data/lib/mongo/cluster/topology/single.rb +1 -1
- data/lib/mongo/collection.rb +26 -0
- data/lib/mongo/collection/view.rb +24 -20
- data/lib/mongo/collection/view/aggregation.rb +25 -4
- data/lib/mongo/collection/view/builder/find_command.rb +38 -18
- data/lib/mongo/collection/view/explainable.rb +27 -8
- data/lib/mongo/collection/view/iterable.rb +72 -12
- data/lib/mongo/collection/view/readable.rb +12 -2
- data/lib/mongo/collection/view/writable.rb +15 -1
- data/lib/mongo/crypt/encryption_io.rb +6 -6
- data/lib/mongo/cursor.rb +1 -0
- data/lib/mongo/database.rb +6 -0
- data/lib/mongo/error.rb +2 -0
- data/lib/mongo/error/invalid_read_concern.rb +28 -0
- data/lib/mongo/error/server_certificate_revoked.rb +22 -0
- data/lib/mongo/error/unsupported_option.rb +14 -12
- data/lib/mongo/lint.rb +2 -1
- data/lib/mongo/logger.rb +3 -3
- data/lib/mongo/operation.rb +2 -0
- data/lib/mongo/operation/aggregate/result.rb +9 -8
- data/lib/mongo/operation/collections_info/result.rb +2 -0
- data/lib/mongo/operation/delete/bulk_result.rb +2 -0
- data/lib/mongo/operation/delete/result.rb +3 -0
- data/lib/mongo/operation/explain/command.rb +4 -0
- data/lib/mongo/operation/explain/legacy.rb +4 -0
- data/lib/mongo/operation/explain/op_msg.rb +6 -0
- data/lib/mongo/operation/explain/result.rb +3 -0
- data/lib/mongo/operation/find/legacy/result.rb +2 -0
- data/lib/mongo/operation/find/result.rb +3 -0
- data/lib/mongo/operation/get_more/result.rb +3 -0
- data/lib/mongo/operation/indexes/result.rb +5 -0
- data/lib/mongo/operation/insert/bulk_result.rb +5 -0
- data/lib/mongo/operation/insert/result.rb +5 -0
- data/lib/mongo/operation/list_collections/result.rb +5 -0
- data/lib/mongo/operation/map_reduce/result.rb +10 -0
- data/lib/mongo/operation/parallel_scan/result.rb +4 -0
- data/lib/mongo/operation/result.rb +35 -6
- data/lib/mongo/operation/shared/bypass_document_validation.rb +1 -0
- data/lib/mongo/operation/shared/causal_consistency_supported.rb +1 -0
- data/lib/mongo/operation/shared/collections_info_or_list_collections.rb +2 -0
- data/lib/mongo/operation/shared/executable.rb +1 -0
- data/lib/mongo/operation/shared/idable.rb +2 -1
- data/lib/mongo/operation/shared/limited.rb +1 -0
- data/lib/mongo/operation/shared/object_id_generator.rb +1 -0
- data/lib/mongo/operation/shared/result/aggregatable.rb +1 -0
- data/lib/mongo/operation/shared/sessions_supported.rb +1 -0
- data/lib/mongo/operation/shared/specifiable.rb +1 -0
- data/lib/mongo/operation/shared/write.rb +1 -0
- data/lib/mongo/operation/shared/write_concern_supported.rb +1 -0
- data/lib/mongo/operation/update/legacy/result.rb +7 -0
- data/lib/mongo/operation/update/result.rb +8 -0
- data/lib/mongo/operation/users_info/result.rb +3 -0
- data/lib/mongo/query_cache.rb +242 -0
- data/lib/mongo/retryable.rb +8 -1
- data/lib/mongo/server.rb +5 -1
- data/lib/mongo/server/connection_common.rb +2 -2
- data/lib/mongo/server/connection_pool.rb +3 -0
- data/lib/mongo/server/monitor.rb +1 -1
- data/lib/mongo/server/monitor/connection.rb +3 -3
- data/lib/mongo/server/pending_connection.rb +2 -2
- data/lib/mongo/server/push_monitor.rb +1 -1
- data/lib/mongo/server_selector/base.rb +5 -1
- data/lib/mongo/session.rb +3 -0
- data/lib/mongo/socket.rb +6 -4
- data/lib/mongo/socket/ocsp_cache.rb +97 -0
- data/lib/mongo/socket/ocsp_verifier.rb +368 -0
- data/lib/mongo/socket/ssl.rb +45 -24
- data/lib/mongo/srv/monitor.rb +7 -13
- data/lib/mongo/srv/resolver.rb +14 -10
- data/lib/mongo/timeout.rb +2 -0
- data/lib/mongo/uri.rb +21 -390
- data/lib/mongo/uri/options_mapper.rb +582 -0
- data/lib/mongo/uri/srv_protocol.rb +3 -2
- data/lib/mongo/utils.rb +12 -1
- data/lib/mongo/version.rb +1 -1
- data/spec/NOTES.aws-auth.md +12 -7
- data/spec/README.md +56 -1
- data/spec/integration/bulk_write_spec.rb +48 -0
- data/spec/integration/client_authentication_options_spec.rb +55 -28
- data/spec/integration/connection_pool_populator_spec.rb +3 -1
- data/spec/integration/cursor_reaping_spec.rb +53 -17
- data/spec/integration/ocsp_connectivity_spec.rb +26 -0
- data/spec/integration/ocsp_verifier_cache_spec.rb +188 -0
- data/spec/integration/ocsp_verifier_spec.rb +334 -0
- data/spec/integration/query_cache_spec.rb +1045 -0
- data/spec/integration/query_cache_transactions_spec.rb +179 -0
- data/spec/integration/retryable_writes/retryable_writes_40_and_newer_spec.rb +1 -0
- data/spec/integration/retryable_writes/shared/performs_legacy_retries.rb +2 -0
- data/spec/integration/sdam_error_handling_spec.rb +68 -0
- data/spec/integration/server_selection_spec.rb +36 -0
- data/spec/integration/srv_monitoring_spec.rb +38 -3
- data/spec/integration/srv_spec.rb +56 -0
- data/spec/lite_spec_helper.rb +3 -1
- data/spec/mongo/address_spec.rb +1 -1
- data/spec/mongo/caching_cursor_spec.rb +70 -0
- data/spec/mongo/client_construction_spec.rb +54 -1
- data/spec/mongo/client_spec.rb +40 -0
- data/spec/mongo/cluster/topology/single_spec.rb +14 -5
- data/spec/mongo/cluster_spec.rb +3 -0
- data/spec/mongo/collection/view/explainable_spec.rb +87 -4
- data/spec/mongo/collection/view/map_reduce_spec.rb +2 -0
- data/spec/mongo/collection_spec.rb +60 -0
- data/spec/mongo/crypt/auto_decryption_context_spec.rb +1 -1
- data/spec/mongo/crypt/auto_encryption_context_spec.rb +1 -1
- data/spec/mongo/crypt/explicit_decryption_context_spec.rb +1 -1
- data/spec/mongo/crypt/explicit_encryption_context_spec.rb +1 -1
- data/spec/mongo/database_spec.rb +44 -0
- data/spec/mongo/error/no_server_available_spec.rb +1 -1
- data/spec/mongo/logger_spec.rb +13 -11
- data/spec/mongo/query_cache_spec.rb +279 -0
- data/spec/mongo/server/connection_pool_spec.rb +7 -3
- data/spec/mongo/server/connection_spec.rb +14 -7
- data/spec/mongo/socket/ssl_spec.rb +1 -1
- data/spec/mongo/socket_spec.rb +1 -1
- data/spec/mongo/uri/srv_protocol_spec.rb +64 -33
- data/spec/mongo/uri_option_parsing_spec.rb +11 -11
- data/spec/mongo/uri_spec.rb +68 -41
- data/spec/mongo/utils_spec.rb +39 -0
- data/spec/runners/auth.rb +3 -0
- data/spec/runners/connection_string.rb +35 -124
- data/spec/spec_tests/cmap_spec.rb +7 -3
- data/spec/spec_tests/data/change_streams/change-streams-errors.yml +0 -1
- data/spec/spec_tests/data/change_streams/change-streams.yml +0 -1
- data/spec/spec_tests/data/cmap/pool-checkout-connection.yml +6 -2
- data/spec/spec_tests/data/cmap/pool-create-min-size.yml +3 -0
- data/spec/spec_tests/data/connection_string/valid-warnings.yml +24 -0
- data/spec/spec_tests/data/sdam_monitoring/discovered_standalone.yml +1 -3
- data/spec/spec_tests/data/sdam_monitoring/standalone.yml +2 -2
- data/spec/spec_tests/data/sdam_monitoring/standalone_repeated.yml +2 -2
- data/spec/spec_tests/data/sdam_monitoring/standalone_suppress_equal_description_changes.yml +2 -2
- data/spec/spec_tests/data/sdam_monitoring/standalone_to_rs_with_me_mismatch.yml +2 -2
- data/spec/spec_tests/data/uri_options/auth-options.yml +25 -0
- data/spec/spec_tests/data/uri_options/compression-options.yml +6 -3
- data/spec/spec_tests/data/uri_options/read-preference-options.yml +24 -0
- data/spec/spec_tests/data/uri_options/ruby-connection-options.yml +1 -0
- data/spec/spec_tests/data/uri_options/tls-options.yml +160 -4
- data/spec/spec_tests/dns_seedlist_discovery_spec.rb +9 -1
- data/spec/spec_tests/uri_options_spec.rb +31 -33
- data/spec/support/certificates/atlas-ocsp-ca.crt +28 -0
- data/spec/support/certificates/atlas-ocsp.crt +41 -0
- data/spec/support/client_registry_macros.rb +11 -2
- data/spec/support/common_shortcuts.rb +45 -0
- data/spec/support/constraints.rb +23 -0
- data/spec/support/lite_constraints.rb +24 -0
- data/spec/support/matchers.rb +16 -0
- data/spec/support/ocsp +1 -0
- data/spec/support/session_registry.rb +52 -0
- data/spec/support/spec_config.rb +22 -0
- data/spec/support/utils.rb +19 -1
- metadata +38 -3
- metadata.gz.sig +0 -0
data/lib/mongo/database.rb
CHANGED
@@ -263,6 +263,7 @@ module Mongo
|
|
263
263
|
# @param [ Hash ] options The options for the operation.
|
264
264
|
#
|
265
265
|
# @option options [ Session ] :session The session to use for the operation.
|
266
|
+
# @option opts [ Hash ] :write_concern The write concern options.
|
266
267
|
#
|
267
268
|
# @return [ Result ] The result of the command.
|
268
269
|
#
|
@@ -270,6 +271,11 @@ module Mongo
|
|
270
271
|
def drop(options = {})
|
271
272
|
operation = { :dropDatabase => 1 }
|
272
273
|
client.send(:with_session, options) do |session|
|
274
|
+
write_concern = if options[:write_concern]
|
275
|
+
WriteConcern.get(options[:write_concern])
|
276
|
+
else
|
277
|
+
self.write_concern
|
278
|
+
end
|
273
279
|
Operation::DropDatabase.new({
|
274
280
|
selector: operation,
|
275
281
|
db_name: name,
|
data/lib/mongo/error.rb
CHANGED
@@ -188,6 +188,7 @@ require 'mongo/error/invalid_min_pool_size'
|
|
188
188
|
require 'mongo/error/invalid_read_option'
|
189
189
|
require 'mongo/error/invalid_application_name'
|
190
190
|
require 'mongo/error/invalid_nonce'
|
191
|
+
require 'mongo/error/invalid_read_concern'
|
191
192
|
require 'mongo/error/invalid_replacement_document'
|
192
193
|
require 'mongo/error/invalid_server_auth_response'
|
193
194
|
# Subclass of InvalidServerAuthResponse
|
@@ -215,6 +216,7 @@ require 'mongo/error/session_ended'
|
|
215
216
|
require 'mongo/error/sessions_not_supported'
|
216
217
|
require 'mongo/error/pool_closed_error'
|
217
218
|
require 'mongo/error/raise_original_error'
|
219
|
+
require 'mongo/error/server_certificate_revoked'
|
218
220
|
require 'mongo/error/socket_error'
|
219
221
|
require 'mongo/error/socket_timeout_error'
|
220
222
|
require 'mongo/error/failed_string_prep_validation'
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# Copyright (C) 2020 MongoDB Inc.
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
#
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
#
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
# See the License for the specific language governing permissions and
|
13
|
+
# limitations under the License.
|
14
|
+
|
15
|
+
module Mongo
|
16
|
+
class Error
|
17
|
+
|
18
|
+
# Raised when an invalid read concern is provided.
|
19
|
+
class InvalidReadConcern < Error
|
20
|
+
# Instantiate the new exception.
|
21
|
+
def initialize(msg = nil)
|
22
|
+
super(msg || 'Invalid read concern option provided.' \
|
23
|
+
'The only valid key is :level, for which accepted values are' \
|
24
|
+
':local, :majority, and :snapshot')
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# Copyright (C) 2020 MongoDB Inc.
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
#
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
#
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
# See the License for the specific language governing permissions and
|
13
|
+
# limitations under the License.
|
14
|
+
|
15
|
+
module Mongo
|
16
|
+
class Error
|
17
|
+
|
18
|
+
# Server certificate has been revoked (determined via OCSP).
|
19
|
+
class ServerCertificateRevoked < Error
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -17,39 +17,39 @@ module Mongo
|
|
17
17
|
|
18
18
|
# Raised if an unsupported option is specified for an operation.
|
19
19
|
class UnsupportedOption < Error
|
20
|
-
# @api private
|
21
|
-
#
|
22
20
|
# The error message provided when the user passes the hint option to
|
23
21
|
# a write operation against a server that does not support the hint
|
24
22
|
# option and does not provide option validation.
|
23
|
+
#
|
24
|
+
# @api private
|
25
25
|
HINT_MESSAGE = "The MongoDB server handling this request does not support " \
|
26
26
|
"the hint option on this command. The hint option is supported on update " \
|
27
27
|
"commands on MongoDB server versions 4.2 and later and on findAndModify " \
|
28
28
|
"and delete commands on MongoDB server versions 4.4 and later"
|
29
29
|
|
30
|
-
# @api private
|
31
|
-
#
|
32
30
|
# The error message provided when the user passes the hint option to
|
33
31
|
# an unacknowledged write operation.
|
32
|
+
#
|
33
|
+
# @api private
|
34
34
|
UNACKNOWLEDGED_HINT_MESSAGE = "The hint option cannot be specified on " \
|
35
35
|
"an unacknowledged write operation. Remove the hint option or perform " \
|
36
36
|
"this operation with a write concern of at least { w: 1 }"
|
37
37
|
|
38
|
-
# @api private
|
39
|
-
#
|
40
38
|
# The error message provided when the user passes the allow_disk_use
|
41
39
|
# option to a find operation against a server that does not support the
|
42
40
|
# allow_disk_use operation and does not provide option validation.
|
41
|
+
#
|
42
|
+
# @api private
|
43
43
|
ALLOW_DISK_USE_MESSAGE = "The MongoDB server handling this request does " \
|
44
44
|
"not support the allow_disk_use option on this command. The " \
|
45
45
|
"allow_disk_use option is supported on find commands on MongoDB " \
|
46
46
|
"server versions 4.4 and later"
|
47
47
|
|
48
|
-
# @api private
|
49
|
-
#
|
50
48
|
# The error message provided when the user passes the commit_quorum option
|
51
49
|
# to a createIndexes operation against a server that does not support
|
52
50
|
# that option.
|
51
|
+
#
|
52
|
+
# @api private
|
53
53
|
COMMIT_QUORUM_MESSAGE = "The MongoDB server handling this request does " \
|
54
54
|
"not support the commit_quorum option on this command. The commit_quorum " \
|
55
55
|
"option is supported on createIndexes commands on MongoDB server versions " \
|
@@ -57,14 +57,14 @@ module Mongo
|
|
57
57
|
|
58
58
|
# Raise an error about an unsupported hint option.
|
59
59
|
#
|
60
|
-
# @param [ Hash ] options
|
61
|
-
#
|
62
60
|
# @option options [ Boolean ] unacknowledged_write Whether this error
|
63
61
|
# pertains to a hint option passed to an unacknowledged write. Defaults
|
64
62
|
# to false.
|
65
63
|
#
|
66
64
|
# @return [ Mongo::Error::UnsupportedOption ] An error with a default
|
67
65
|
# error message.
|
66
|
+
#
|
67
|
+
# @api private
|
68
68
|
def self.hint_error(**options)
|
69
69
|
unacknowledged_write = options[:unacknowledged_write] || false
|
70
70
|
|
@@ -79,10 +79,10 @@ module Mongo
|
|
79
79
|
|
80
80
|
# Raise an error about an unsupported allow_disk_use option.
|
81
81
|
#
|
82
|
-
# @param [ Hash ] options
|
83
|
-
#
|
84
82
|
# @return [ Mongo::Error::UnsupportedOption ] An error with a default
|
85
83
|
# error message.
|
84
|
+
#
|
85
|
+
# @api private
|
86
86
|
def self.allow_disk_use_error
|
87
87
|
new(ALLOW_DISK_USE_MESSAGE)
|
88
88
|
end
|
@@ -91,6 +91,8 @@ module Mongo
|
|
91
91
|
#
|
92
92
|
# @return [ Mongo::Error::UnsupportedOption ] An error with a default
|
93
93
|
# error message.
|
94
|
+
#
|
95
|
+
# @api private
|
94
96
|
def self.commit_quorum_error
|
95
97
|
new(COMMIT_QUORUM_MESSAGE)
|
96
98
|
end
|
data/lib/mongo/lint.rb
CHANGED
@@ -4,12 +4,13 @@ module Mongo
|
|
4
4
|
module Lint
|
5
5
|
|
6
6
|
# Raises LintError if +obj+ is not of type +cls+.
|
7
|
-
|
7
|
+
def assert_type(obj, cls)
|
8
8
|
return unless enabled?
|
9
9
|
unless obj.is_a?(cls)
|
10
10
|
raise Error::LintError, "Expected #{obj} to be a #{cls}"
|
11
11
|
end
|
12
12
|
end
|
13
|
+
module_function :assert_type
|
13
14
|
|
14
15
|
def validate_underscore_read_preference(read_pref)
|
15
16
|
return unless enabled?
|
data/lib/mongo/logger.rb
CHANGED
@@ -21,7 +21,7 @@ module Mongo
|
|
21
21
|
|
22
22
|
class << self
|
23
23
|
|
24
|
-
# Get the wrapped logger. If none was set will return a default
|
24
|
+
# Get the wrapped logger. If none was set will return a default info
|
25
25
|
# level logger.
|
26
26
|
#
|
27
27
|
# @example Get the wrapped logger.
|
@@ -75,8 +75,8 @@ module Mongo
|
|
75
75
|
private
|
76
76
|
|
77
77
|
def default_logger
|
78
|
-
logger = ::Logger.new(
|
79
|
-
logger.level = ::Logger::
|
78
|
+
logger = ::Logger.new(STDOUT)
|
79
|
+
logger.level = ::Logger::INFO
|
80
80
|
logger
|
81
81
|
end
|
82
82
|
end
|
data/lib/mongo/operation.rb
CHANGED
@@ -14,25 +14,24 @@
|
|
14
14
|
|
15
15
|
module Mongo
|
16
16
|
module Operation
|
17
|
-
|
18
|
-
# Aggregate result wrapper.
|
19
|
-
#
|
20
|
-
# @since 2.0.0
|
21
17
|
class Aggregate
|
22
18
|
|
23
19
|
# Defines custom behavior of results in an aggregation context.
|
24
20
|
#
|
25
21
|
# @since 2.0.0
|
22
|
+
# @api semiprivate
|
26
23
|
class Result < Operation::Result
|
27
24
|
|
28
25
|
# The field name for the aggregation explain information.
|
29
26
|
#
|
30
27
|
# @since 2.0.5
|
28
|
+
# @api private
|
31
29
|
EXPLAIN = 'stages'.freeze
|
32
30
|
|
33
31
|
# The legacy field name for the aggregation explain information.
|
34
32
|
#
|
35
33
|
# @since 2.0.5
|
34
|
+
# @api private
|
36
35
|
EXPLAIN_LEGACY = 'serverPipeline'.freeze
|
37
36
|
|
38
37
|
# Get the cursor id for the result.
|
@@ -48,6 +47,7 @@ module Mongo
|
|
48
47
|
# @return [ Integer ] The cursor id.
|
49
48
|
#
|
50
49
|
# @since 2.0.0
|
50
|
+
# @api private
|
51
51
|
def cursor_id
|
52
52
|
cursor_document ? cursor_document[CURSOR_ID] : 0
|
53
53
|
end
|
@@ -62,8 +62,8 @@ module Mongo
|
|
62
62
|
end
|
63
63
|
|
64
64
|
# Get the documents for the aggregation result. This is either the
|
65
|
-
# first document's 'result' field, or if a cursor option was selected,
|
66
|
-
# it is the 'firstBatch' field in the 'cursor' field of the first
|
65
|
+
# first document's 'result' field, or if a cursor option was selected,
|
66
|
+
# it is the 'firstBatch' field in the 'cursor' field of the first
|
67
67
|
# document returned. Otherwise, it is an explain document.
|
68
68
|
#
|
69
69
|
# @example Get the documents.
|
@@ -72,10 +72,11 @@ module Mongo
|
|
72
72
|
# @return [ Array<BSON::Document> ] The documents.
|
73
73
|
#
|
74
74
|
# @since 2.0.0
|
75
|
+
# @api public
|
75
76
|
def documents
|
76
|
-
docs = reply.documents[0][RESULT]
|
77
|
+
docs = reply.documents[0][RESULT]
|
77
78
|
docs ||= cursor_document[FIRST_BATCH] if cursor_document
|
78
|
-
docs ||= explain_document
|
79
|
+
docs ||= explain_document
|
79
80
|
docs
|
80
81
|
end
|
81
82
|
|
@@ -20,6 +20,7 @@ module Mongo
|
|
20
20
|
# collection.
|
21
21
|
#
|
22
22
|
# @since 2.1.0
|
23
|
+
# @api semiprivate
|
23
24
|
class Result < Operation::Result
|
24
25
|
|
25
26
|
# Get the namespace for the cursor.
|
@@ -30,6 +31,7 @@ module Mongo
|
|
30
31
|
# @return [ String ] The namespace.
|
31
32
|
#
|
32
33
|
# @since 2.1.0
|
34
|
+
# @api private
|
33
35
|
def namespace
|
34
36
|
Database::NAMESPACES
|
35
37
|
end
|
@@ -19,6 +19,7 @@ module Mongo
|
|
19
19
|
# Defines custom behavior of results for a delete when part of a bulk write.
|
20
20
|
#
|
21
21
|
# @since 2.0.0
|
22
|
+
# @api semiprivate
|
22
23
|
class BulkResult < Operation::Result
|
23
24
|
include Aggregatable
|
24
25
|
|
@@ -30,6 +31,7 @@ module Mongo
|
|
30
31
|
# @return [ Integer ] The number of documents deleted.
|
31
32
|
#
|
32
33
|
# @since 2.0.0
|
34
|
+
# @api public
|
33
35
|
def n_removed
|
34
36
|
return 0 unless acknowledged?
|
35
37
|
@replies.reduce(0) do |n, reply|
|
@@ -19,6 +19,7 @@ module Mongo
|
|
19
19
|
# Defines custom behavior of results for a delete.
|
20
20
|
#
|
21
21
|
# @since 2.0.0
|
22
|
+
# @api semiprivate
|
22
23
|
class Result < Operation::Result
|
23
24
|
|
24
25
|
# Get the number of documents deleted.
|
@@ -29,10 +30,12 @@ module Mongo
|
|
29
30
|
# @return [ Integer ] The deleted count.
|
30
31
|
#
|
31
32
|
# @since 2.0.0
|
33
|
+
# @api public
|
32
34
|
def deleted_count
|
33
35
|
n
|
34
36
|
end
|
35
37
|
|
38
|
+
# @api public
|
36
39
|
def bulk_result
|
37
40
|
BulkResult.new(@replies, connection_description)
|
38
41
|
end
|
@@ -19,6 +19,7 @@ module Mongo
|
|
19
19
|
# Defines custom behavior of results in find command with explain.
|
20
20
|
#
|
21
21
|
# @since 2.5.0
|
22
|
+
# @api semiprivate
|
22
23
|
class Result < Operation::Result
|
23
24
|
|
24
25
|
# Get the cursor id.
|
@@ -29,6 +30,7 @@ module Mongo
|
|
29
30
|
# @return [ 0 ] Always 0 because explain doesn't return a cursor.
|
30
31
|
#
|
31
32
|
# @since 2.5.0
|
33
|
+
# @api private
|
32
34
|
def cursor_id
|
33
35
|
0
|
34
36
|
end
|
@@ -41,6 +43,7 @@ module Mongo
|
|
41
43
|
# @return [ Array<BSON::Document> ] The documents.
|
42
44
|
#
|
43
45
|
# @since 2.5.0
|
46
|
+
# @api public
|
44
47
|
def documents
|
45
48
|
reply.documents
|
46
49
|
end
|
@@ -20,6 +20,7 @@ module Mongo
|
|
20
20
|
# Defines custom behavior of results for a query.
|
21
21
|
#
|
22
22
|
# @since 2.1.0
|
23
|
+
# @api semiprivate
|
23
24
|
class Result < Operation::Result
|
24
25
|
include Operation::Result::UseLegacyErrorParser
|
25
26
|
|
@@ -31,6 +32,7 @@ module Mongo
|
|
31
32
|
# @return [ true, false ] If the query was successful.
|
32
33
|
#
|
33
34
|
# @since 2.0.0
|
35
|
+
# @api public
|
34
36
|
def successful?
|
35
37
|
!query_failure?
|
36
38
|
end
|
@@ -19,6 +19,7 @@ module Mongo
|
|
19
19
|
# Defines custom behavior of results in find command.
|
20
20
|
#
|
21
21
|
# @since 2.2.0
|
22
|
+
# @api semiprivate
|
22
23
|
class Result < Operation::Result
|
23
24
|
|
24
25
|
# Get the cursor id.
|
@@ -29,6 +30,7 @@ module Mongo
|
|
29
30
|
# @return [ Integer ] The cursor id.
|
30
31
|
#
|
31
32
|
# @since 2.2.0
|
33
|
+
# @api private
|
32
34
|
def cursor_id
|
33
35
|
cursor_document ? cursor_document[CURSOR_ID] : super
|
34
36
|
end
|
@@ -41,6 +43,7 @@ module Mongo
|
|
41
43
|
# @return [ Array<BSON::Document> ] The documents.
|
42
44
|
#
|
43
45
|
# @since 2.2.0
|
46
|
+
# @api public
|
44
47
|
def documents
|
45
48
|
cursor_document[FIRST_BATCH]
|
46
49
|
end
|
@@ -19,6 +19,7 @@ module Mongo
|
|
19
19
|
# Defines custom behavior of results for the get more command.
|
20
20
|
#
|
21
21
|
# @since 2.2.0
|
22
|
+
# @api semiprivate
|
22
23
|
class Result < Operation::Result
|
23
24
|
|
24
25
|
# Get the cursor id.
|
@@ -29,6 +30,7 @@ module Mongo
|
|
29
30
|
# @return [ Integer ] The cursor id.
|
30
31
|
#
|
31
32
|
# @since 2.2.0
|
33
|
+
# @api private
|
32
34
|
def cursor_id
|
33
35
|
cursor_document ? cursor_document[CURSOR_ID] : super
|
34
36
|
end
|
@@ -50,6 +52,7 @@ module Mongo
|
|
50
52
|
# @return [ Array<BSON::Document> ] The documents.
|
51
53
|
#
|
52
54
|
# @since 2.2.0
|
55
|
+
# @api public
|
53
56
|
def documents
|
54
57
|
cursor_document[NEXT_BATCH]
|
55
58
|
end
|