mongo 2.18.0 → 2.18.2

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.
Files changed (118) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data/lib/mongo/bulk_write.rb +7 -5
  4. data/lib/mongo/client.rb +1 -1
  5. data/lib/mongo/collection/view/writable.rb +0 -2
  6. data/lib/mongo/collection.rb +150 -45
  7. data/lib/mongo/crypt/auto_encrypter.rb +30 -9
  8. data/lib/mongo/crypt/binding.rb +93 -1
  9. data/lib/mongo/crypt/explicit_encrypter.rb +5 -1
  10. data/lib/mongo/crypt/handle.rb +33 -0
  11. data/lib/mongo/crypt/kms.rb +0 -1
  12. data/lib/mongo/cursor.rb +6 -1
  13. data/lib/mongo/error/invalid_read_option.rb +1 -1
  14. data/lib/mongo/operation/aggregate.rb +1 -2
  15. data/lib/mongo/operation/collections_info.rb +3 -15
  16. data/lib/mongo/operation/command.rb +1 -2
  17. data/lib/mongo/operation/count.rb +1 -2
  18. data/lib/mongo/operation/create.rb +1 -2
  19. data/lib/mongo/operation/create_index.rb +1 -2
  20. data/lib/mongo/operation/create_user.rb +1 -2
  21. data/lib/mongo/operation/delete.rb +0 -1
  22. data/lib/mongo/operation/distinct.rb +1 -2
  23. data/lib/mongo/operation/drop.rb +1 -2
  24. data/lib/mongo/operation/drop_database.rb +1 -2
  25. data/lib/mongo/operation/drop_index.rb +1 -2
  26. data/lib/mongo/operation/explain.rb +1 -3
  27. data/lib/mongo/operation/find/builder.rb +0 -1
  28. data/lib/mongo/operation/find.rb +1 -3
  29. data/lib/mongo/operation/get_more.rb +1 -3
  30. data/lib/mongo/operation/indexes.rb +1 -17
  31. data/lib/mongo/operation/insert.rb +0 -1
  32. data/lib/mongo/operation/kill_cursors.rb +1 -2
  33. data/lib/mongo/operation/list_collections.rb +1 -2
  34. data/lib/mongo/operation/map_reduce.rb +1 -2
  35. data/lib/mongo/operation/parallel_scan.rb +1 -2
  36. data/lib/mongo/operation/remove_user.rb +1 -2
  37. data/lib/mongo/operation/shared/{polymorphic_operation.rb → op_msg_executable.rb} +11 -6
  38. data/lib/mongo/operation/shared/sessions_supported.rb +7 -3
  39. data/lib/mongo/operation/update.rb +0 -1
  40. data/lib/mongo/operation/update_user.rb +1 -2
  41. data/lib/mongo/operation/users_info.rb +1 -2
  42. data/lib/mongo/operation/write_command.rb +1 -2
  43. data/lib/mongo/operation.rb +1 -3
  44. data/lib/mongo/protocol.rb +0 -3
  45. data/lib/mongo/query_cache.rb +20 -20
  46. data/lib/mongo/session.rb +1 -1
  47. data/lib/mongo/version.rb +1 -1
  48. data/spec/README.md +5 -1
  49. data/spec/integration/bulk_write_spec.rb +16 -0
  50. data/spec/integration/command_spec.rb +1 -23
  51. data/spec/integration/ocsp_verifier_spec.rb +2 -0
  52. data/spec/mongo/client_construction_spec.rb +4 -4
  53. data/spec/mongo/collection_crud_spec.rb +56 -0
  54. data/spec/mongo/collection_spec.rb +11 -1
  55. data/spec/mongo/crypt/auto_encrypter_spec.rb +41 -6
  56. data/spec/mongo/crypt/binding/version_spec.rb +8 -0
  57. data/spec/mongo/crypt/handle_spec.rb +102 -0
  58. data/spec/mongo/crypt/kms_spec.rb +12 -9
  59. data/spec/mongo/cursor_spec.rb +50 -0
  60. data/spec/shared/lib/mrss/event_subscriber.rb +15 -5
  61. data/spec/spec_tests/data/change_streams_unified/change-streams-resume-errorLabels.yml +3 -0
  62. data/spec/spec_tests/data/client_side_encryption/unified/rewrapManyDataKey.yml +3 -3
  63. data/spec/spec_tests/data/sdam_integration/hello-command-error.yml +6 -14
  64. data/spec/spec_tests/data/sdam_integration/hello-network-error.yml +4 -14
  65. data/spec/spec_tests/data/sdam_integration/hello-timeout.yml +8 -14
  66. data/spec/spec_tests/data/transactions_unified/do-not-retry-read-in-transaction.yml +64 -0
  67. data/spec/spec_tests/data/transactions_unified/retryable-abort-handshake.yml +118 -0
  68. data/spec/spec_tests/data/transactions_unified/retryable-commit-handshake.yml +118 -0
  69. data/spec/support/certificates/retrieve-atlas-cert +38 -0
  70. data/spec/support/spec_config.rb +4 -0
  71. data.tar.gz.sig +0 -0
  72. metadata +1133 -1178
  73. metadata.gz.sig +0 -0
  74. data/lib/mongo/operation/aggregate/command.rb +0 -55
  75. data/lib/mongo/operation/collections_info/command.rb +0 -48
  76. data/lib/mongo/operation/command/command.rb +0 -41
  77. data/lib/mongo/operation/count/command.rb +0 -47
  78. data/lib/mongo/operation/create/command.rb +0 -47
  79. data/lib/mongo/operation/create_index/command.rb +0 -61
  80. data/lib/mongo/operation/create_user/command.rb +0 -46
  81. data/lib/mongo/operation/delete/command.rb +0 -52
  82. data/lib/mongo/operation/distinct/command.rb +0 -47
  83. data/lib/mongo/operation/drop/command.rb +0 -41
  84. data/lib/mongo/operation/drop_database/command.rb +0 -41
  85. data/lib/mongo/operation/drop_index/command.rb +0 -45
  86. data/lib/mongo/operation/explain/command.rb +0 -58
  87. data/lib/mongo/operation/explain/legacy.rb +0 -52
  88. data/lib/mongo/operation/find/builder/legacy.rb +0 -123
  89. data/lib/mongo/operation/find/command.rb +0 -51
  90. data/lib/mongo/operation/find/legacy/result.rb +0 -46
  91. data/lib/mongo/operation/find/legacy.rb +0 -52
  92. data/lib/mongo/operation/get_more/command.rb +0 -43
  93. data/lib/mongo/operation/get_more/legacy.rb +0 -39
  94. data/lib/mongo/operation/indexes/command.rb +0 -42
  95. data/lib/mongo/operation/indexes/legacy.rb +0 -48
  96. data/lib/mongo/operation/insert/command.rb +0 -55
  97. data/lib/mongo/operation/kill_cursors/command.rb +0 -48
  98. data/lib/mongo/operation/list_collections/command.rb +0 -46
  99. data/lib/mongo/operation/map_reduce/command.rb +0 -51
  100. data/lib/mongo/operation/parallel_scan/command.rb +0 -57
  101. data/lib/mongo/operation/remove_user/command.rb +0 -46
  102. data/lib/mongo/operation/shared/op_msg_or_command.rb +0 -41
  103. data/lib/mongo/operation/shared/op_msg_or_find_command.rb +0 -44
  104. data/lib/mongo/operation/update/command.rb +0 -53
  105. data/lib/mongo/operation/update_user/command.rb +0 -45
  106. data/lib/mongo/operation/users_info/command.rb +0 -46
  107. data/lib/mongo/operation/write_command/command.rb +0 -51
  108. data/lib/mongo/protocol/delete.rb +0 -172
  109. data/lib/mongo/protocol/insert.rb +0 -181
  110. data/lib/mongo/protocol/update.rb +0 -214
  111. data/spec/mongo/operation/delete/command_spec.rb +0 -115
  112. data/spec/mongo/operation/find/legacy_spec.rb +0 -131
  113. data/spec/mongo/operation/get_more_spec.rb +0 -63
  114. data/spec/mongo/operation/insert/command_spec.rb +0 -118
  115. data/spec/mongo/operation/update/command_spec.rb +0 -122
  116. data/spec/mongo/protocol/delete_spec.rb +0 -185
  117. data/spec/mongo/protocol/insert_spec.rb +0 -179
  118. data/spec/mongo/protocol/update_spec.rb +0 -204
@@ -1,57 +0,0 @@
1
- # frozen_string_literal: true
2
- # encoding: utf-8
3
-
4
- # Copyright (C) 2018-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
- module Mongo
19
- module Operation
20
- class ParallelScan
21
-
22
- # A MongoDB parallelscan operation sent as a command message.
23
- #
24
- # @api private
25
- #
26
- # @since 2.5.2
27
- class Command
28
- include Specifiable
29
- include Executable
30
- include Limited
31
- include ReadPreferenceSupported
32
- include PolymorphicResult
33
-
34
- private
35
-
36
- def selector(connection)
37
- sel = { :parallelCollectionScan => coll_name, :numCursors => cursor_count }
38
- if read_concern
39
- sel[:readConcern] = Options::Mapper.transform_values_to_strings(
40
- read_concern)
41
- end
42
- sel[:maxTimeMS] = max_time_ms if max_time_ms
43
- add_read_preference_legacy(sel, connection)
44
- end
45
-
46
- def message(connection)
47
- Protocol::Query.new(db_name, Database::COMMAND, command(connection), options(connection))
48
- end
49
- end
50
- end
51
- end
52
- end
53
-
54
-
55
-
56
-
57
-
@@ -1,46 +0,0 @@
1
- # frozen_string_literal: true
2
- # encoding: utf-8
3
-
4
- # Copyright (C) 2018-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
- module Mongo
19
- module Operation
20
- class RemoveUser
21
-
22
- # A MongoDB removeuser operation sent as a command message.
23
- #
24
- # @api private
25
- #
26
- # @since 2.5.2
27
- class Command
28
- include Specifiable
29
- include Executable
30
- include Limited
31
- include ReadPreferenceSupported
32
- include WriteConcernSupported
33
-
34
- private
35
-
36
- def selector(connection)
37
- { :dropUser => user_name }
38
- end
39
-
40
- def message(connection)
41
- Protocol::Query.new(db_name, Database::COMMAND, command(connection), options(connection))
42
- end
43
- end
44
- end
45
- end
46
- end
@@ -1,41 +0,0 @@
1
- # frozen_string_literal: true
2
- # encoding: utf-8
3
-
4
- # Copyright (C) 2018-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
- module Mongo
19
- module Operation
20
-
21
- # Shared behavior of executing the operation as an OpMsg when supported
22
- # or as a Command otherwise.
23
- #
24
- # @api private
25
- module OpMsgOrCommand
26
- include PolymorphicOperation
27
- include PolymorphicLookup
28
-
29
- private
30
-
31
- def final_operation(connection)
32
- cls = if connection.features.op_msg_enabled?
33
- polymorphic_class(self.class.name, :OpMsg)
34
- else
35
- polymorphic_class(self.class.name, :Command)
36
- end
37
- cls.new(spec)
38
- end
39
- end
40
- end
41
- end
@@ -1,44 +0,0 @@
1
- # frozen_string_literal: true
2
- # encoding: utf-8
3
-
4
- # Copyright (C) 2018-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
- module Mongo
19
- module Operation
20
-
21
- # Shared behavior of executing the operation as an OpMsg when supported,
22
- # as a Command when find command is supported by the server, and as
23
- # Legacy otherwise.
24
- #
25
- # @api private
26
- module OpMsgOrFindCommand
27
- include PolymorphicOperation
28
- include PolymorphicLookup
29
-
30
- private
31
-
32
- def final_operation(connection)
33
- cls = if connection.features.op_msg_enabled?
34
- polymorphic_class(self.class.name, :OpMsg)
35
- elsif connection.features.find_command_enabled?
36
- polymorphic_class(self.class.name, :Command)
37
- else
38
- polymorphic_class(self.class.name, :Legacy)
39
- end
40
- cls.new(spec)
41
- end
42
- end
43
- end
44
- end
@@ -1,53 +0,0 @@
1
- # frozen_string_literal: true
2
- # encoding: utf-8
3
-
4
- # Copyright (C) 2018-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
- module Mongo
19
- module Operation
20
- class Update
21
-
22
- # A MongoDB update operation sent as a command message.
23
- #
24
- # @api private
25
- #
26
- # @since 2.5.2
27
- class Command
28
- include Specifiable
29
- include Executable
30
- include Limited
31
- include WriteConcernSupported
32
- include BypassDocumentValidation
33
- include ExecutableNoValidate
34
- include PolymorphicResult
35
- include Validatable
36
-
37
- private
38
-
39
- def selector(connection)
40
- {
41
- update: coll_name,
42
- updates: validate_updates(connection, send(IDENTIFIER)),
43
- ordered: ordered?,
44
- }
45
- end
46
-
47
- def message(connection)
48
- Protocol::Query.new(db_name, Database::COMMAND, command(connection), options(connection))
49
- end
50
- end
51
- end
52
- end
53
- end
@@ -1,45 +0,0 @@
1
- # frozen_string_literal: true
2
- # encoding: utf-8
3
-
4
- # Copyright (C) 2018-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
- module Mongo
19
- module Operation
20
- class UpdateUser
21
-
22
- # A MongoDB updateuser operation sent as a command message.
23
- #
24
- # @api private
25
- #
26
- # @since 2.5.2
27
- class Command
28
- include Specifiable
29
- include Executable
30
- include Limited
31
- include WriteConcernSupported
32
-
33
- private
34
-
35
- def selector(connection)
36
- { :updateUser => user.name }.merge(user.spec)
37
- end
38
-
39
- def message(connection)
40
- Protocol::Query.new(db_name, Database::COMMAND, command(connection), options(connection))
41
- end
42
- end
43
- end
44
- end
45
- end
@@ -1,46 +0,0 @@
1
- # frozen_string_literal: true
2
- # encoding: utf-8
3
-
4
- # Copyright (C) 2018-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
- module Mongo
19
- module Operation
20
- class UsersInfo
21
-
22
- # A MongoDB usersinfo operation sent as a command message.
23
- #
24
- # @api private
25
- #
26
- # @since 2.5.2
27
- class Command
28
- include Specifiable
29
- include Executable
30
- include Limited
31
- include ReadPreferenceSupported
32
- include PolymorphicResult
33
-
34
- private
35
-
36
- def selector(connection)
37
- { :usersInfo => user_name }
38
- end
39
-
40
- def message(connection)
41
- Protocol::Query.new(db_name, Database::COMMAND, command(connection), options(connection))
42
- end
43
- end
44
- end
45
- end
46
- end
@@ -1,51 +0,0 @@
1
- # frozen_string_literal: true
2
- # encoding: utf-8
3
-
4
- # Copyright (C) 2021 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
- module Mongo
19
- module Operation
20
- class WriteCommand
21
-
22
- # A MongoDB write command operation sent as a command message.
23
- #
24
- # @api private
25
- class Command
26
- include Specifiable
27
- include Executable
28
- include Limited
29
- include ReadPreferenceSupported
30
- include Validatable
31
-
32
- private
33
-
34
- def selector(connection)
35
- super.tap do |selector|
36
- if selector.key?(:findAndModify)
37
- validate_find_options(connection, selector)
38
- end
39
- if wc = spec[:write_concern]
40
- selector[:writeConcern] = wc.options
41
- end
42
- end
43
- end
44
-
45
- def message(connection)
46
- Protocol::Query.new(db_name, Database::COMMAND, command(connection), options(connection))
47
- end
48
- end
49
- end
50
- end
51
- end
@@ -1,172 +0,0 @@
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
- module Mongo
19
- module Protocol
20
-
21
- # MongoDB Wire protocol Delete message.
22
- #
23
- # This is a client request message that is sent to the server in order
24
- # to delete selected documents in the specified namespace.
25
- #
26
- # The operation, by default, operates on many documents. Setting
27
- # the +:single_remove+ flag allows for a single matching document
28
- # to be removed.
29
- #
30
- # @api semipublic
31
- class Delete < Message
32
-
33
- # Creates a new Delete message
34
- #
35
- # @example Remove all users named Tyler.
36
- # Query.new('xgen', 'users', {:name => 'Tyler'})
37
- #
38
- # @param database [String, Symbol] The database to remove from.
39
- # @param collection [String, Symbol] The collection to remove from.
40
- # @param selector [Hash] The query used to select doc(s) to remove.
41
- # @param options [Hash] The additional delete options.
42
- #
43
- # @option options :flags [Array] The flags for the delete message.
44
- #
45
- # Supported flags: +:single_remove+
46
- def initialize(database, collection, selector, options = {})
47
- @database = database
48
- @namespace = "#{database}.#{collection}"
49
- @selector = selector
50
- @flags = options[:flags] || []
51
- @upconverter = Upconverter.new(collection, selector, options)
52
- super
53
- end
54
-
55
- # Return the event payload for monitoring.
56
- #
57
- # @example Return the event payload.
58
- # message.payload
59
- #
60
- # @return [ BSON::Document ] The event payload.
61
- #
62
- # @since 2.1.0
63
- def payload
64
- BSON::Document.new(
65
- command_name: 'delete',
66
- database_name: @database,
67
- command: upconverter.command,
68
- request_id: request_id
69
- )
70
- end
71
-
72
- protected
73
-
74
- attr_reader :upconverter
75
-
76
- private
77
-
78
- # The operation code required to specify a Delete message.
79
- # @return [Fixnum] the operation code.
80
- #
81
- # @since 2.5.0
82
- OP_CODE = 2006
83
-
84
- # Available flags for a Delete message.
85
- FLAGS = [:single_remove]
86
-
87
- # Field representing Zero encoded as an Int32.
88
- field :zero, Zero
89
-
90
- # @!attribute
91
- # @return [String] The namespace for this Delete message.
92
- field :namespace, CString
93
-
94
- # @!attribute
95
- # @return [Array<Symbol>] The flags for this Delete message.
96
- field :flags, BitVector.new(FLAGS)
97
-
98
- # @!attribute
99
- # @return [Hash] The selector for this Delete message.
100
- field :selector, Document
101
-
102
- # Converts legacy delete messages to the appropriare OP_COMMAND style
103
- # message.
104
- #
105
- # @since 2.1.0
106
- class Upconverter
107
-
108
- # The delete command constant.
109
- #
110
- # @since 2.2.0
111
- DELETE = 'delete'.freeze
112
-
113
- # The deletes command constant.
114
- #
115
- # @since 2.2.0
116
- DELETES = 'deletes'.freeze
117
-
118
- # @return [ String ] collection The name of the collection.
119
- attr_reader :collection
120
-
121
- # @return [ BSON::Document, Hash ] filter The query filter or command.
122
- attr_reader :filter
123
-
124
- # @return [ Hash ] options The options.
125
- attr_reader :options
126
-
127
- # Instantiate the upconverter.
128
- #
129
- # @example Instantiate the upconverter.
130
- # Upconverter.new('users', { name: 'test' })
131
- #
132
- # @param [ String ] collection The name of the collection.
133
- # @param [ BSON::Document, Hash ] filter The filter or command.
134
- #
135
- # @since 2.1.0
136
- def initialize(collection, filter, options)
137
- @collection = collection
138
- @filter = filter
139
- @options = options
140
- end
141
-
142
- # Get the upconverted command.
143
- #
144
- # @example Get the command.
145
- # upconverter.command
146
- #
147
- # @return [ BSON::Document ] The upconverted command.
148
- #
149
- # @since 2.1.0
150
- def command
151
- document = BSON::Document.new
152
- document.store(DELETE, collection)
153
- document.store(DELETES, [ BSON::Document.new(Message::Q => filter, Message::LIMIT => limit) ])
154
- document.store(Message::ORDERED, true)
155
- document
156
- end
157
-
158
- private
159
-
160
- def limit
161
- if options.key?(:flags)
162
- options[:flags].include?(:single_remove) ? 1 : 0
163
- else
164
- 0
165
- end
166
- end
167
- end
168
-
169
- Registry.register(OP_CODE, self)
170
- end
171
- end
172
- end