mongo 2.18.1 → 2.18.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (94) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data/lib/mongo/bulk_write.rb +6 -4
  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/kms.rb +0 -1
  8. data/lib/mongo/error/invalid_read_option.rb +1 -1
  9. data/lib/mongo/operation/aggregate.rb +1 -2
  10. data/lib/mongo/operation/collections_info.rb +3 -15
  11. data/lib/mongo/operation/command.rb +1 -2
  12. data/lib/mongo/operation/count.rb +1 -2
  13. data/lib/mongo/operation/create.rb +1 -2
  14. data/lib/mongo/operation/create_index.rb +1 -2
  15. data/lib/mongo/operation/create_user.rb +1 -2
  16. data/lib/mongo/operation/delete.rb +0 -1
  17. data/lib/mongo/operation/distinct.rb +1 -2
  18. data/lib/mongo/operation/drop.rb +1 -2
  19. data/lib/mongo/operation/drop_database.rb +1 -2
  20. data/lib/mongo/operation/drop_index.rb +1 -2
  21. data/lib/mongo/operation/explain.rb +1 -3
  22. data/lib/mongo/operation/find/builder.rb +0 -1
  23. data/lib/mongo/operation/find.rb +1 -3
  24. data/lib/mongo/operation/get_more.rb +1 -3
  25. data/lib/mongo/operation/indexes.rb +1 -17
  26. data/lib/mongo/operation/insert.rb +0 -1
  27. data/lib/mongo/operation/kill_cursors.rb +1 -2
  28. data/lib/mongo/operation/list_collections.rb +1 -2
  29. data/lib/mongo/operation/map_reduce.rb +1 -2
  30. data/lib/mongo/operation/parallel_scan.rb +1 -2
  31. data/lib/mongo/operation/remove_user.rb +1 -2
  32. data/lib/mongo/operation/shared/{polymorphic_operation.rb → op_msg_executable.rb} +11 -6
  33. data/lib/mongo/operation/update.rb +0 -1
  34. data/lib/mongo/operation/update_user.rb +1 -2
  35. data/lib/mongo/operation/users_info.rb +1 -2
  36. data/lib/mongo/operation/write_command.rb +1 -2
  37. data/lib/mongo/operation.rb +1 -3
  38. data/lib/mongo/protocol.rb +0 -3
  39. data/lib/mongo/query_cache.rb +20 -20
  40. data/lib/mongo/session.rb +1 -1
  41. data/lib/mongo/version.rb +1 -1
  42. data/spec/integration/command_spec.rb +1 -23
  43. data/spec/mongo/client_construction_spec.rb +4 -4
  44. data/spec/mongo/collection_crud_spec.rb +56 -0
  45. data/spec/mongo/collection_spec.rb +11 -1
  46. data/spec/mongo/crypt/kms_spec.rb +12 -9
  47. data.tar.gz.sig +0 -0
  48. metadata +1133 -1186
  49. metadata.gz.sig +0 -0
  50. data/lib/mongo/operation/aggregate/command.rb +0 -55
  51. data/lib/mongo/operation/collections_info/command.rb +0 -48
  52. data/lib/mongo/operation/command/command.rb +0 -41
  53. data/lib/mongo/operation/count/command.rb +0 -47
  54. data/lib/mongo/operation/create/command.rb +0 -47
  55. data/lib/mongo/operation/create_index/command.rb +0 -61
  56. data/lib/mongo/operation/create_user/command.rb +0 -46
  57. data/lib/mongo/operation/delete/command.rb +0 -52
  58. data/lib/mongo/operation/distinct/command.rb +0 -47
  59. data/lib/mongo/operation/drop/command.rb +0 -41
  60. data/lib/mongo/operation/drop_database/command.rb +0 -41
  61. data/lib/mongo/operation/drop_index/command.rb +0 -45
  62. data/lib/mongo/operation/explain/command.rb +0 -58
  63. data/lib/mongo/operation/explain/legacy.rb +0 -52
  64. data/lib/mongo/operation/find/builder/legacy.rb +0 -123
  65. data/lib/mongo/operation/find/command.rb +0 -51
  66. data/lib/mongo/operation/find/legacy/result.rb +0 -46
  67. data/lib/mongo/operation/find/legacy.rb +0 -52
  68. data/lib/mongo/operation/get_more/command.rb +0 -43
  69. data/lib/mongo/operation/get_more/legacy.rb +0 -39
  70. data/lib/mongo/operation/indexes/command.rb +0 -42
  71. data/lib/mongo/operation/indexes/legacy.rb +0 -48
  72. data/lib/mongo/operation/insert/command.rb +0 -55
  73. data/lib/mongo/operation/kill_cursors/command.rb +0 -48
  74. data/lib/mongo/operation/list_collections/command.rb +0 -46
  75. data/lib/mongo/operation/map_reduce/command.rb +0 -51
  76. data/lib/mongo/operation/parallel_scan/command.rb +0 -57
  77. data/lib/mongo/operation/remove_user/command.rb +0 -46
  78. data/lib/mongo/operation/shared/op_msg_or_command.rb +0 -41
  79. data/lib/mongo/operation/shared/op_msg_or_find_command.rb +0 -44
  80. data/lib/mongo/operation/update/command.rb +0 -53
  81. data/lib/mongo/operation/update_user/command.rb +0 -45
  82. data/lib/mongo/operation/users_info/command.rb +0 -46
  83. data/lib/mongo/operation/write_command/command.rb +0 -51
  84. data/lib/mongo/protocol/delete.rb +0 -172
  85. data/lib/mongo/protocol/insert.rb +0 -181
  86. data/lib/mongo/protocol/update.rb +0 -214
  87. data/spec/mongo/operation/delete/command_spec.rb +0 -115
  88. data/spec/mongo/operation/find/legacy_spec.rb +0 -131
  89. data/spec/mongo/operation/get_more_spec.rb +0 -63
  90. data/spec/mongo/operation/insert/command_spec.rb +0 -118
  91. data/spec/mongo/operation/update/command_spec.rb +0 -122
  92. data/spec/mongo/protocol/delete_spec.rb +0 -185
  93. data/spec/mongo/protocol/insert_spec.rb +0 -179
  94. data/spec/mongo/protocol/update_spec.rb +0 -204
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 664d381d4746fb4ff6282069f909a91a58f497220bae57656c265f52c5d99040
4
- data.tar.gz: 85fa7fbf071c3e8fc4c1beb2215b3297a3af560130204dbd0f916adb272987f7
3
+ metadata.gz: 44bd3e615b9e0e11f3803eae60a44b56fe5be326b7dd8f78b3c5aa42fbf7e621
4
+ data.tar.gz: 124bfd17f02e5b929e8b40dc797146770096270a83f7ea2389890efe83af1fbe
5
5
  SHA512:
6
- metadata.gz: 2dcf66e773da4e2bdaf0a22d15a06eadbc5ab2bccffc29f012e2ae863e8148b597550ee680dc2556b40408f4c759b78b159b678cf494cf619c0975044d72d662
7
- data.tar.gz: c120607792132931a54511db0a4ef62653393138e9da3fcf0ca0f0a85fde3aefe6b04782fd09125b0fe3085e50c66b1cd2f6e0c4743ae40e7094dc8e7892587a
6
+ metadata.gz: 675df13e076a6a8b94e187e493cefb8fe4e1697cafdb4241898519f55b5abf3cceff7db1e9424bc2defdcba5a218e1bd8b149572ab891319c7c8a42f9699706a
7
+ data.tar.gz: 7593ef22c16038dc53e7e4e04c615dbc39c083bdffb6ef7d99f583d64613909079c7edb2b5e367117e0b3dca19a0a57ba3eb0ac92701bde48d750557a17cf567
checksums.yaml.gz.sig CHANGED
Binary file
@@ -115,7 +115,8 @@ module Mongo
115
115
  # )
116
116
  #
117
117
  # @param [ Mongo::Collection ] collection The collection.
118
- # @param [ Array<Hash, BSON::Document> ] requests The requests, cannot be empty.
118
+ # @param [ Enumerable<Hash, BSON::Document> ] requests The requests,
119
+ # cannot be empty.
119
120
  # @param [ Hash, BSON::Document ] options The options.
120
121
  #
121
122
  # @since 2.1.0
@@ -330,10 +331,9 @@ module Mongo
330
331
  # ArgumentError ]
331
332
  # if the document is invalid.
332
333
  def validate_requests!
333
- if @requests.empty?
334
- raise ArgumentError, "Bulk write requests cannot be empty"
335
- end
334
+ requests_empty = true
336
335
  @requests.each do |req|
336
+ requests_empty = false
337
337
  if op = req.keys.first
338
338
  if [:update_one, :update_many].include?(op)
339
339
  if doc = maybe_first(req.dig(op, :update))
@@ -359,6 +359,8 @@ module Mongo
359
359
  end
360
360
  end
361
361
  end
362
+ end.tap do
363
+ raise ArgumentError, "Bulk write requests cannot be empty" if requests_empty
362
364
  end
363
365
  end
364
366
 
data/lib/mongo/client.rb CHANGED
@@ -1570,7 +1570,7 @@ module Mongo
1570
1570
  # for custom classes implementing key access ([]).
1571
1571
  # Instead reject common cases of strings and symbols.
1572
1572
  if read.is_a?(String) || read.is_a?(Symbol)
1573
- raise Error::InvalidReadOption.new(read, 'must be a hash')
1573
+ raise Error::InvalidReadOption.new(read, "the read preference must be specified as a hash: { mode: #{read.inspect} }")
1574
1574
  end
1575
1575
 
1576
1576
  if mode = read[:mode]
@@ -98,8 +98,6 @@ module Mongo
98
98
  end.first&.fetch('value', nil)
99
99
  end
100
100
 
101
- # db['users'].bulk_write([{insert_one: {x: 1}}, {insert_one: {x: 2}}])
102
-
103
101
  # Finds a single document and replaces it.
104
102
  #
105
103
  # @example Find a document and replace it, returning the original.
@@ -83,7 +83,7 @@ module Mongo
83
83
  #
84
84
  # @param [ Object ] other The object to check.
85
85
  #
86
- # @return [ true, false ] If the objects are equal.
86
+ # @return [ true | false ] If the objects are equal.
87
87
  #
88
88
  # @since 2.0.0
89
89
  def ==(other)
@@ -100,19 +100,59 @@ module Mongo
100
100
  # @param [ String, Symbol ] name The collection name.
101
101
  # @param [ Hash ] options The collection options.
102
102
  #
103
- # @option options [ Hash ] :write Deprecated. Equivalent to :write_concern
103
+ # @option opts [ true | false ] :capped Create a fixed-sized collection.
104
+ # @option opts [ Hash ] :change_stream_pre_and_post_images Used to enable
105
+ # pre- and post-images on the created collection.
106
+ # The hash may have the following items:
107
+ # - *:enabled* -- true or false.
108
+ # @option opts [ Hash ] :clustered_index Create a clustered index.
109
+ # This option specifies how this collection should be clustered on _id.
110
+ # The hash may have the following items:
111
+ # - *:key* -- The clustered index key field. Must be set to { _id: 1 }.
112
+ # - *:unique* -- Must be set to true. The collection will not accept
113
+ # inserted or updated documents where the clustered index key value
114
+ # matches an existing value in the index.
115
+ # - *:name* -- Optional. A name that uniquely identifies the clustered index.
116
+ # @option opts [ Hash ] :collation The collation to use.
117
+ # @option opts [ Hash ] :encrypted_fields Hash describing encrypted fields
118
+ # for queryable encryption.
119
+ # @option opts [ Integer ] :expire_after Number indicating
120
+ # after how many seconds old time-series data should be deleted.
121
+ # @option opts [ Integer ] :max The maximum number of documents in a
122
+ # capped collection. The size limit takes precedents over max.
123
+ # @option opts [ Array<Hash> ] :pipeline An array of pipeline stages.
124
+ # A view will be created by applying this pipeline to the view_on
125
+ # collection or view.
126
+ # @option options [ Hash ] :read_concern The read concern options hash,
127
+ # with the following optional keys:
128
+ # - *:level* -- the read preference level as a symbol; valid values
129
+ # are *:local*, *:majority*, and *:snapshot*
130
+ # @option options [ Hash ] :read The read preference options.
131
+ # The hash may have the following items:
132
+ # - *:mode* -- read preference specified as a symbol; valid values are
133
+ # *:primary*, *:primary_preferred*, *:secondary*, *:secondary_preferred*
134
+ # and *:nearest*.
135
+ # - *:tag_sets* -- an array of hashes.
136
+ # - *:local_threshold*.
137
+ # @option opts [ Session ] :session The session to use for the operation.
138
+ # @option opts [ Integer ] :size The size of the capped collection.
139
+ # @option opts [ Hash ] :time_series Create a time-series collection.
140
+ # The hash may have the following items:
141
+ # - *:timeField* -- The name of the field which contains the date in each
142
+ # time series document.
143
+ # - *:metaField* -- The name of the field which contains metadata in each
144
+ # time series document.
145
+ # - *:granularity* -- Set the granularity to the value that is the closest
146
+ # match to the time span between consecutive incoming measurements.
147
+ # Possible values are "seconds" (default), "minutes", and "hours".
148
+ # @option opts [ Hash ] :validator Hash describing document validation
149
+ # options for the collection.
150
+ # @option opts [ String ] :view_on The name of the source collection or
151
+ # view from which to create a view.
152
+ # @option opts [ Hash ] :write Deprecated. Equivalent to :write_concern
104
153
  # option.
105
- # @option options [ Hash ] :write_concern The write concern options.
154
+ # @option opts [ Hash ] :write_concern The write concern options.
106
155
  # Can be :w => Integer|String, :fsync => Boolean, :j => Boolean.
107
- # @option options [ Hash ] :time_series Create a time-series collection.
108
- # See https://mongodb.com/docs/manual/core/timeseries-collections/ for more
109
- # information about time-series collection.
110
- # @option options [ Integer ] :expire_after Number indicating
111
- # after how many seconds old time-series data should be deleted.
112
- # @options clustered_index [ Hash ] :clustered_index Create a clustered index.
113
- # This option specifies how this collection should be clustered on _id.
114
- # See https://www.mongodb.com/docs/v5.3/reference/method/db.createCollection/#std-label-db.createCollection.clusteredIndex
115
- # for more information about this option.
116
156
  #
117
157
  # @since 2.0.0
118
158
  def initialize(database, name, options = {})
@@ -204,17 +244,37 @@ module Mongo
204
244
  wc
205
245
  end
206
246
 
207
- # Provides a new collection with either a new read preference or new write concern
208
- # merged over the existing read preference / write concern.
247
+ # Provides a new collection with either a new read preference, new read
248
+ # concern or new write concern merged over the existing read preference /
249
+ # read concern / write concern.
209
250
  #
210
251
  # @example Get a collection with a changed read preference.
211
252
  # collection.with(read: { mode: :primary_preferred })
253
+
254
+ # @example Get a collection with a changed read concern.
255
+ # collection.with(read_concern: { level: :majority })
212
256
  #
213
257
  # @example Get a collection with a changed write concern.
214
258
  # collection.with(write_concern: { w: 3 })
215
-
259
+ #
216
260
  # @param [ Hash ] new_options The new options to use.
217
261
  #
262
+ # @option new_options [ Hash ] :read The read preference options.
263
+ # The hash may have the following items:
264
+ # - *:mode* -- read preference specified as a symbol; valid values are
265
+ # *:primary*, *:primary_preferred*, *:secondary*, *:secondary_preferred*
266
+ # and *:nearest*.
267
+ # - *:tag_sets* -- an array of hashes.
268
+ # - *:local_threshold*.
269
+ # @option new_options [ Hash ] :read_concern The read concern options hash,
270
+ # with the following optional keys:
271
+ # - *:level* -- the read preference level as a symbol; valid values
272
+ # are *:local*, *:majority*, and *:snapshot*
273
+ # @option new_options [ Hash ] :write Deprecated. Equivalent to :write_concern
274
+ # option.
275
+ # @option new_options [ Hash ] :write_concern The write concern options.
276
+ # Can be :w => Integer|String, :fsync => Boolean, :j => Boolean.
277
+ #
218
278
  # @return [ Mongo::Collection ] A new collection instance.
219
279
  #
220
280
  # @since 2.1.0
@@ -237,7 +297,7 @@ module Mongo
237
297
  # @example Is the collection capped?
238
298
  # collection.capped?
239
299
  #
240
- # @return [ true, false ] If the collection is capped.
300
+ # @return [ true | false ] If the collection is capped.
241
301
  #
242
302
  # @since 2.0.0
243
303
  def capped?
@@ -251,17 +311,48 @@ module Mongo
251
311
  #
252
312
  # @param [ Hash ] opts The options for the create operation.
253
313
  #
254
- # @option opts [ Session ] :session The session to use for the operation.
255
- # @option opts [ Hash ] :write_concern The write concern options.
256
- # @option opts [ Hash ] :time_series Create a time-series collection.
257
- # @option opts [ Integer ] :expire_after Number indicating
258
- # after how many seconds old time-series data should be deleted.
314
+ # @option opts [ true | false ] :capped Create a fixed-sized collection.
259
315
  # @option opts [ Hash ] :change_stream_pre_and_post_images Used to enable
260
316
  # pre- and post-images on the created collection.
317
+ # The hash may have the following items:
318
+ # - *:enabled* -- true or false.
319
+ # @option opts [ Hash ] :clustered_index Create a clustered index.
320
+ # This option specifies how this collection should be clustered on _id.
321
+ # The hash may have the following items:
322
+ # - *:key* -- The clustered index key field. Must be set to { _id: 1 }.
323
+ # - *:unique* -- Must be set to true. The collection will not accept
324
+ # inserted or updated documents where the clustered index key value
325
+ # matches an existing value in the index.
326
+ # - *:name* -- Optional. A name that uniquely identifies the clustered index.
327
+ # @option opts [ Hash ] :collation The collation to use.
261
328
  # @option opts [ Hash ] :encrypted_fields Hash describing encrypted fields
262
329
  # for queryable encryption.
330
+ # @option opts [ Integer ] :expire_after Number indicating
331
+ # after how many seconds old time-series data should be deleted.
332
+ # @option opts [ Integer ] :max The maximum number of documents in a
333
+ # capped collection. The size limit takes precedents over max.
334
+ # @option opts [ Array<Hash> ] :pipeline An array of pipeline stages.
335
+ # A view will be created by applying this pipeline to the view_on
336
+ # collection or view.
337
+ # @option opts [ Session ] :session The session to use for the operation.
338
+ # @option opts [ Integer ] :size The size of the capped collection.
339
+ # @option opts [ Hash ] :time_series Create a time-series collection.
340
+ # The hash may have the following items:
341
+ # - *:timeField* -- The name of the field which contains the date in each
342
+ # time series document.
343
+ # - *:metaField* -- The name of the field which contains metadata in each
344
+ # time series document.
345
+ # - *:granularity* -- Set the granularity to the value that is the closest
346
+ # match to the time span between consecutive incoming measurements.
347
+ # Possible values are "seconds" (default), "minutes", and "hours".
263
348
  # @option opts [ Hash ] :validator Hash describing document validation
264
349
  # options for the collection.
350
+ # @option opts [ String ] :view_on The name of the source collection or
351
+ # view from which to create a view.
352
+ # @option opts [ Hash ] :write Deprecated. Equivalent to :write_concern
353
+ # option.
354
+ # @option opts [ Hash ] :write_concern The write concern options.
355
+ # Can be :w => Integer|String, :fsync => Boolean, :j => Boolean.
265
356
  #
266
357
  # @return [ Result ] The result of the command.
267
358
  #
@@ -318,8 +409,10 @@ module Mongo
318
409
  #
319
410
  # @param [ Hash ] opts The options for the drop operation.
320
411
  #
321
- # @option options [ Session ] :session The session to use for the operation.
412
+ # @option opts [ Session ] :session The session to use for the operation.
322
413
  # @option opts [ Hash ] :write_concern The write concern options.
414
+ # @option opts [ Hash | nil ] :encrypted_fields Encrypted fields hash that
415
+ # was provided to `create` collection helper.
323
416
  #
324
417
  # @return [ Result ] The result of the command.
325
418
  #
@@ -356,27 +449,27 @@ module Mongo
356
449
  # @param [ Hash ] filter The filter to use in the find.
357
450
  # @param [ Hash ] options The options for the find.
358
451
  #
359
- # @option options [ true, false ] :allow_disk_use When set to true, the
452
+ # @option options [ true | false ] :allow_disk_use When set to true, the
360
453
  # server can write temporary data to disk while executing the find
361
454
  # operation. This option is only available on MongoDB server versions
362
455
  # 4.4 and newer.
363
- # @option options [ true, false ] :allow_partial_results Allows the query to get partial
456
+ # @option options [ true | false ] :allow_partial_results Allows the query to get partial
364
457
  # results if some shards are down.
365
458
  # @option options [ Integer ] :batch_size The number of documents returned in each batch
366
459
  # of results from MongoDB.
367
460
  # @option options [ Hash ] :collation The collation to use.
368
- # @option options [ Object ] :comment A user-provided
369
- # comment to attach to this command.
461
+ # @option options [ Object ] :comment A user-provided comment to attach to
462
+ # this command.
370
463
  # @option options [ :tailable, :tailable_await ] :cursor_type The type of cursor to use.
371
464
  # @option options [ Integer ] :limit The max number of docs to return from the query.
372
465
  # @option options [ Integer ] :max_time_ms
373
466
  # The maximum amount of time to allow the query to run, in milliseconds.
374
467
  # @option options [ Hash ] :modifiers A document containing meta-operators modifying the
375
468
  # output or behavior of a query.
376
- # @option options [ true, false ] :no_cursor_timeout The server normally times out idle
469
+ # @option options [ true | false ] :no_cursor_timeout The server normally times out idle
377
470
  # cursors after an inactivity period (10 minutes) to prevent excess memory use.
378
471
  # Set this option to prevent that.
379
- # @option options [ true, false ] :oplog_replay For internal replication
472
+ # @option options [ true | false ] :oplog_replay For internal replication
380
473
  # use only, applications should not set this option.
381
474
  # @option options [ Hash ] :projection The fields to include or exclude from each doc
382
475
  # in the result set.
@@ -402,11 +495,11 @@ module Mongo
402
495
  # @param [ Array<Hash> ] pipeline The aggregation pipeline.
403
496
  # @param [ Hash ] options The aggregation options.
404
497
  #
405
- # @option options [ true, false ] :allow_disk_use Set to true if disk
498
+ # @option options [ true | false ] :allow_disk_use Set to true if disk
406
499
  # usage is allowed during the aggregation.
407
500
  # @option options [ Integer ] :batch_size The number of documents to return
408
501
  # per batch.
409
- # @option options [ true, false ] :bypass_document_validation Whether or
502
+ # @option options [ true | false ] :bypass_document_validation Whether or
410
503
  # not to skip document level validation.
411
504
  # @option options [ Hash ] :collation The collation to use.
412
505
  # @option options [ Object ] :comment A user-provided
@@ -416,7 +509,7 @@ module Mongo
416
509
  # See the server documentation for details.
417
510
  # @option options [ Integer ] :max_time_ms The maximum amount of time in
418
511
  # milliseconds to allow the aggregation to run.
419
- # @option options [ true, false ] :use_cursor Indicates whether the command
512
+ # @option options [ true | false ] :use_cursor Indicates whether the command
420
513
  # will request that the server provide results using a cursor. Note that
421
514
  # as of server version 3.6, aggregations always provide results using a
422
515
  # cursor and this option is therefore not valid.
@@ -642,7 +735,13 @@ module Mongo
642
735
  # @param [ Hash ] document The document to insert.
643
736
  # @param [ Hash ] opts The insert options.
644
737
  #
738
+ # @option opts [ true | false ] :bypass_document_validation Whether or
739
+ # not to skip document level validation.
740
+ # @option opts [ Object ] :comment A user-provided comment to attach to
741
+ # this command.
645
742
  # @option opts [ Session ] :session The session to use for the operation.
743
+ # @option opts [ Hash ] :write_concern The write concern options.
744
+ # Can be :w => Integer, :fsync => Boolean, :j => Boolean.
646
745
  #
647
746
  # @return [ Result ] The database response wrapper.
648
747
  #
@@ -684,12 +783,18 @@ module Mongo
684
783
  # @example Insert documents into the collection.
685
784
  # collection.insert_many([{ name: 'test' }])
686
785
  #
687
- # @param [ Array<Hash> ] documents The documents to insert.
786
+ # @param [ Enumerable<Hash> ] documents The documents to insert.
688
787
  # @param [ Hash ] options The insert options.
689
788
  #
789
+ # @option options [ true | false ] :bypass_document_validation Whether or
790
+ # not to skip document level validation.
791
+ # @option options [ Object ] :comment A user-provided comment to attach to
792
+ # this command.
690
793
  # @option options [ true | false ] :ordered Whether the operations
691
794
  # should be executed in order.
692
795
  # @option options [ Session ] :session The session to use for the operation.
796
+ # @option options [ Hash ] :write_concern The write concern options.
797
+ # Can be :w => Integer, :fsync => Boolean, :j => Boolean.
693
798
  #
694
799
  # @return [ Result ] The database response wrapper.
695
800
  #
@@ -706,14 +811,14 @@ module Mongo
706
811
  # @example Execute a bulk write.
707
812
  # collection.bulk_write(operations, options)
708
813
  #
709
- # @param [ Array<Hash> ] requests The bulk write requests.
814
+ # @param [ Enumerable<Hash> ] requests The bulk write requests.
710
815
  # @param [ Hash ] options The options.
711
816
  #
712
- # @option options [ true, false ] :ordered Whether the operations
817
+ # @option options [ true | false ] :ordered Whether the operations
713
818
  # should be executed in order.
714
819
  # @option options [ Hash ] :write_concern The write concern options.
715
820
  # Can be :w => Integer, :fsync => Boolean, :j => Boolean.
716
- # @option options [ true, false ] :bypass_document_validation Whether or
821
+ # @option options [ true | false ] :bypass_document_validation Whether or
717
822
  # not to skip document level validation.
718
823
  # @option options [ Session ] :session The session to use for the set of operations.
719
824
  # @option options [ Hash ] :let Mapping of variables to use in the command.
@@ -802,9 +907,9 @@ module Mongo
802
907
  # @param [ Hash ] replacement The replacement document..
803
908
  # @param [ Hash ] options The options.
804
909
  #
805
- # @option options [ true, false ] :upsert Whether to upsert if the
910
+ # @option options [ true | false ] :upsert Whether to upsert if the
806
911
  # document doesn't exist.
807
- # @option options [ true, false ] :bypass_document_validation Whether or
912
+ # @option options [ true | false ] :bypass_document_validation Whether or
808
913
  # not to skip document level validation.
809
914
  # @option options [ Hash ] :collation The collation to use.
810
915
  # @option options [ Session ] :session The session to use.
@@ -829,9 +934,9 @@ module Mongo
829
934
  # @param [ Hash | Array<Hash> ] update The update document or pipeline.
830
935
  # @param [ Hash ] options The options.
831
936
  #
832
- # @option options [ true, false ] :upsert Whether to upsert if the
937
+ # @option options [ true | false ] :upsert Whether to upsert if the
833
938
  # document doesn't exist.
834
- # @option options [ true, false ] :bypass_document_validation Whether or
939
+ # @option options [ true | false ] :bypass_document_validation Whether or
835
940
  # not to skip document level validation.
836
941
  # @option options [ Hash ] :collation The collation to use.
837
942
  # @option options [ Array ] :array_filters A set of filters specifying to which array elements
@@ -858,9 +963,9 @@ module Mongo
858
963
  # @param [ Hash | Array<Hash> ] update The update document or pipeline.
859
964
  # @param [ Hash ] options The options.
860
965
  #
861
- # @option options [ true, false ] :upsert Whether to upsert if the
966
+ # @option options [ true | false ] :upsert Whether to upsert if the
862
967
  # document doesn't exist.
863
- # @option options [ true, false ] :bypass_document_validation Whether or
968
+ # @option options [ true | false ] :bypass_document_validation Whether or
864
969
  # not to skip document level validation.
865
970
  # @option options [ Hash ] :collation The collation to use.
866
971
  # @option options [ Array ] :array_filters A set of filters specifying to which array elements
@@ -927,8 +1032,8 @@ module Mongo
927
1032
  # @option options [ Hash ] :sort The key and direction pairs by which the result set
928
1033
  # will be sorted.
929
1034
  # @option options [ Symbol ] :return_document Either :before or :after.
930
- # @option options [ true, false ] :upsert Whether to upsert if the document doesn't exist.
931
- # @option options [ true, false ] :bypass_document_validation Whether or
1035
+ # @option options [ true | false ] :upsert Whether to upsert if the document doesn't exist.
1036
+ # @option options [ true | false ] :bypass_document_validation Whether or
932
1037
  # not to skip document level validation.
933
1038
  # @option options [ Hash ] :write_concern The write concern options.
934
1039
  # Defaults to the collection's write concern.
@@ -967,8 +1072,8 @@ module Mongo
967
1072
  # @option options [ Hash ] :sort The key and direction pairs by which the result set
968
1073
  # will be sorted.
969
1074
  # @option options [ Symbol ] :return_document Either :before or :after.
970
- # @option options [ true, false ] :upsert Whether to upsert if the document doesn't exist.
971
- # @option options [ true, false ] :bypass_document_validation Whether or
1075
+ # @option options [ true | false ] :upsert Whether to upsert if the document doesn't exist.
1076
+ # @option options [ true | false ] :bypass_document_validation Whether or
972
1077
  # not to skip document level validation.
973
1078
  # @option options [ Hash ] :write_concern The write concern options.
974
1079
  # Defaults to the collection's write concern.
@@ -89,7 +89,6 @@ module Mongo
89
89
  %i(
90
90
  ssl_verify_certificate
91
91
  ssl_verify_hostname
92
- ssl_verify_ocsp_endpoint
93
92
  ).each do |opt|
94
93
  if provider_opts[opt] == false
95
94
  raise ArgumentError.new(
@@ -31,7 +31,7 @@ module Mongo
31
31
  #
32
32
  # @since 2.6.0
33
33
  def initialize(read_option, msg)
34
- super("Invalid read option: #{read_option}: #{msg}")
34
+ super("Invalid read preference value: #{read_option.inspect}: #{msg}")
35
35
  end
36
36
  end
37
37
  end
@@ -15,7 +15,6 @@
15
15
  # See the License for the specific language governing permissions and
16
16
  # limitations under the License.
17
17
 
18
- require 'mongo/operation/aggregate/command'
19
18
  require 'mongo/operation/aggregate/op_msg'
20
19
  require 'mongo/operation/aggregate/result'
21
20
 
@@ -33,7 +32,7 @@ module Mongo
33
32
  # @since 2.0.0
34
33
  class Aggregate
35
34
  include Specifiable
36
- include OpMsgOrCommand
35
+ include OpMsgExecutable
37
36
  end
38
37
  end
39
38
  end
@@ -15,7 +15,6 @@
15
15
  # See the License for the specific language governing permissions and
16
16
  # limitations under the License.
17
17
 
18
- require 'mongo/operation/collections_info/command'
19
18
  require 'mongo/operation/collections_info/result'
20
19
 
21
20
  module Mongo
@@ -28,23 +27,12 @@ module Mongo
28
27
  # @since 2.0.0
29
28
  class CollectionsInfo
30
29
  include Specifiable
31
- include PolymorphicOperation
32
- include PolymorphicLookup
30
+ include OpMsgExecutable
33
31
 
34
32
  private
35
33
 
36
- def final_operation(connection)
37
- op_class = if connection.features.list_collections_enabled?
38
- if connection.features.op_msg_enabled?
39
- ListCollections::OpMsg
40
- else
41
- ListCollections::Command
42
- end
43
- else
44
- CollectionsInfo::Command
45
- end
46
-
47
- op_class.new(spec)
34
+ def final_operation
35
+ ListCollections::OpMsg.new(spec)
48
36
  end
49
37
  end
50
38
  end
@@ -15,7 +15,6 @@
15
15
  # See the License for the specific language governing permissions and
16
16
  # limitations under the License.
17
17
 
18
- require 'mongo/operation/command/command'
19
18
  require 'mongo/operation/command/op_msg'
20
19
 
21
20
  module Mongo
@@ -28,7 +27,7 @@ module Mongo
28
27
  # @since 2.0.0
29
28
  class Command
30
29
  include Specifiable
31
- include OpMsgOrCommand
30
+ include OpMsgExecutable
32
31
  end
33
32
  end
34
33
  end
@@ -15,7 +15,6 @@
15
15
  # See the License for the specific language governing permissions and
16
16
  # limitations under the License.
17
17
 
18
- require 'mongo/operation/count/command'
19
18
  require 'mongo/operation/count/op_msg'
20
19
 
21
20
  module Mongo
@@ -28,7 +27,7 @@ module Mongo
28
27
  # @since 2.0.0
29
28
  class Count
30
29
  include Specifiable
31
- include OpMsgOrCommand
30
+ include OpMsgExecutable
32
31
  end
33
32
  end
34
33
  end
@@ -15,7 +15,6 @@
15
15
  # See the License for the specific language governing permissions and
16
16
  # limitations under the License.
17
17
 
18
- require 'mongo/operation/create/command'
19
18
  require 'mongo/operation/create/op_msg'
20
19
 
21
20
  module Mongo
@@ -28,7 +27,7 @@ module Mongo
28
27
  # @since 2.0.0
29
28
  class Create
30
29
  include Specifiable
31
- include OpMsgOrCommand
30
+ include OpMsgExecutable
32
31
  end
33
32
  end
34
33
  end
@@ -15,7 +15,6 @@
15
15
  # See the License for the specific language governing permissions and
16
16
  # limitations under the License.
17
17
 
18
- require 'mongo/operation/create_index/command'
19
18
  require 'mongo/operation/create_index/op_msg'
20
19
 
21
20
  module Mongo
@@ -28,7 +27,7 @@ module Mongo
28
27
  # @since 2.0.0
29
28
  class CreateIndex
30
29
  include Specifiable
31
- include OpMsgOrCommand
30
+ include OpMsgExecutable
32
31
  end
33
32
  end
34
33
  end
@@ -15,7 +15,6 @@
15
15
  # See the License for the specific language governing permissions and
16
16
  # limitations under the License.
17
17
 
18
- require 'mongo/operation/create_user/command'
19
18
  require 'mongo/operation/create_user/op_msg'
20
19
 
21
20
  module Mongo
@@ -28,7 +27,7 @@ module Mongo
28
27
  # @since 2.0.0
29
28
  class CreateUser
30
29
  include Specifiable
31
- include OpMsgOrCommand
30
+ include OpMsgExecutable
32
31
  end
33
32
  end
34
33
  end
@@ -15,7 +15,6 @@
15
15
  # See the License for the specific language governing permissions and
16
16
  # limitations under the License.
17
17
 
18
- require 'mongo/operation/delete/command'
19
18
  require 'mongo/operation/delete/op_msg'
20
19
  require 'mongo/operation/delete/result'
21
20
  require 'mongo/operation/delete/bulk_result'
@@ -15,7 +15,6 @@
15
15
  # See the License for the specific language governing permissions and
16
16
  # limitations under the License.
17
17
 
18
- require 'mongo/operation/distinct/command'
19
18
  require 'mongo/operation/distinct/op_msg'
20
19
 
21
20
  module Mongo
@@ -28,7 +27,7 @@ module Mongo
28
27
  # @since 2.5.0
29
28
  class Distinct
30
29
  include Specifiable
31
- include OpMsgOrCommand
30
+ include OpMsgExecutable
32
31
  end
33
32
  end
34
33
  end
@@ -15,7 +15,6 @@
15
15
  # See the License for the specific language governing permissions and
16
16
  # limitations under the License.
17
17
 
18
- require 'mongo/operation/drop/command'
19
18
  require 'mongo/operation/drop/op_msg'
20
19
 
21
20
  module Mongo
@@ -28,7 +27,7 @@ module Mongo
28
27
  # @since 2.4.0
29
28
  class Drop
30
29
  include Specifiable
31
- include OpMsgOrCommand
30
+ include OpMsgExecutable
32
31
  end
33
32
  end
34
33
  end
@@ -15,7 +15,6 @@
15
15
  # See the License for the specific language governing permissions and
16
16
  # limitations under the License.
17
17
 
18
- require 'mongo/operation/drop_database/command'
19
18
  require 'mongo/operation/drop_database/op_msg'
20
19
 
21
20
  module Mongo
@@ -28,7 +27,7 @@ module Mongo
28
27
  # @since 2.4.0
29
28
  class DropDatabase
30
29
  include Specifiable
31
- include OpMsgOrCommand
30
+ include OpMsgExecutable
32
31
  end
33
32
  end
34
33
  end
@@ -15,7 +15,6 @@
15
15
  # See the License for the specific language governing permissions and
16
16
  # limitations under the License.
17
17
 
18
- require 'mongo/operation/drop_index/command'
19
18
  require 'mongo/operation/drop_index/op_msg'
20
19
 
21
20
  module Mongo
@@ -28,7 +27,7 @@ module Mongo
28
27
  # @since 2.0.0
29
28
  class DropIndex
30
29
  include Specifiable
31
- include OpMsgOrCommand
30
+ include OpMsgExecutable
32
31
  end
33
32
  end
34
33
  end