Skip to content

Commit f473561

Browse files
p-mongop
andauthored
Fix RUBY-2252 Bulk write documentation references nonexistent insert_many operation (#2048)
Co-authored-by: Oleg Pudeyev <[email protected]>
1 parent 7cd6e31 commit f473561

File tree

1 file changed

+43
-34
lines changed

1 file changed

+43
-34
lines changed

source/tutorials/ruby-driver-bulk-operations.txt

Lines changed: 43 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -12,55 +12,36 @@ Bulk Operations
1212

1313
.. _ruby-driver-bulk-ops:
1414

15-
The bulk write API sends a list of write operations to the server in
16-
one method call. Execution order of the operations is guaranteed if
17-
you pass in the ``ordered`` option.
15+
The bulk write API sends several write operations to the server in a single
16+
command. Use the bulk write API to reduce the number of network round-trips
17+
when performing several writes at a time.
18+
19+
If the ``ordered`` option is set to ``true`` (which is the default),
20+
the operations are applied in order and if any operation fails, subsequent
21+
operations are not attempted. If the ``ordered`` option is set to ``false``,
22+
all specified operations are attempted.
1823

1924
The ``bulk_write`` method takes three arguments:
2025

21-
- A list of operations.
22-
- The ``ordered`` option with a boolean. Defaults to ``true``.
23-
- A write concern option. Defaults to the collection's write concern.
26+
- A list of operations to execute.
27+
- The ``ordered`` option taking a boolean value. Defaults to ``true``.
28+
- The write concern option. Defaults to the collection's write concern.
2429

2530
Valid bulk write operations are the following:
2631

32+
2733
insert_one
2834
==========
2935

3036
.. code-block:: ruby
3137

3238
{ :insert_one => { :x => 1 } }
3339

34-
insert_many
35-
===========
36-
37-
.. code-block:: ruby
38-
39-
{ :insert_many => [ { :x => 1 }, { :x => 2 } ] }
40-
41-
delete_one
42-
==========
43-
44-
.. code-block:: ruby
45-
46-
{ :delete_one => { :filter => { :x => 1 } } }
47-
48-
delete_many
49-
===========
50-
51-
.. code-block:: ruby
52-
53-
{ :delete_many => { :filter => { :x => 1 } } }
54-
55-
replace_one
56-
===========
40+
.. note::
5741

58-
.. code-block:: ruby
42+
There is no ``insert_many`` operation. To insert multiple documents,
43+
specify multiple ``insert_one`` operations.
5944

60-
{ :replace_one => { :filter => { :x => 1 },
61-
:replacement => { :x => 2 },
62-
:upsert => true } # upsert is optional and defaults to false
63-
}
6445

6546
update_one
6647
==========
@@ -72,6 +53,7 @@ update_one
7253
:upsert => true } # upsert is optional and defaults to false
7354
}
7455

56+
7557
update_many
7658
===========
7759

@@ -100,3 +82,30 @@ to the ``bulk_write`` method.
10082
}
10183
],
10284
:ordered => true)
85+
86+
87+
replace_one
88+
===========
89+
90+
.. code-block:: ruby
91+
92+
{ :replace_one => { :filter => { :x => 1 },
93+
:replacement => { :x => 2 },
94+
:upsert => true } # upsert is optional and defaults to false
95+
}
96+
97+
98+
delete_one
99+
==========
100+
101+
.. code-block:: ruby
102+
103+
{ :delete_one => { :filter => { :x => 1 } } }
104+
105+
106+
delete_many
107+
===========
108+
109+
.. code-block:: ruby
110+
111+
{ :delete_many => { :filter => { :x => 1 } } }

0 commit comments

Comments
 (0)