Skip to content

Commit f58428a

Browse files
Add documentation for bulk API find()
1 parent e15deb1 commit f58428a

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

lib/mongo/bulk_write_collection_view.rb

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,21 @@ def inspect
9292

9393
# Modify the query selector for subsequent bulk write operations.
9494
# The default query selector on creation of the bulk write view is {}.
95+
# For operations that require a query selector, find() must be set
96+
# per operation, or set once for all operations on the bulk object.
97+
# For example, these operations:
98+
#
99+
# bulk.find({"a" => 2}).update({"$inc" => {"x" => 2}})
100+
# bulk.find({"a" => 2}).update({"$set" => {"b" => 3}})
101+
#
102+
# may be rewritten as:
103+
#
104+
# bulk = find({"a" => 2})
105+
# bulk.update({"$inc" => {"x" => 2}})
106+
# bulk.update({"$set" => {"b" => 3}})
107+
#
108+
# Note that modifying the query selector in this way will not affect
109+
# operations that do not use a query selector, like insert().
95110
#
96111
# @param [Hash] q the query selector
97112
#

0 commit comments

Comments
 (0)