Skip to content

Commit 27ec651

Browse files
authored
Merge pull request #843 from steveren/DOCS-9125
DOCS-9125: projections tutorial update
2 parents 0376e28 + d9e3241 commit 27ec651

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

source/tutorials/ruby-driver-projections.txt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ following form:
2626

2727
.. code-block:: javascript
2828

29-
{ field1: <value>, field2: <value> ... }
29+
{ 'projection': { field1: <value>, field2: <value> ... } }
3030

3131
``<value>`` may be ``0`` (or ``false``) to exclude the field, or
3232
``1`` (or ``true``) to include it. With the exception of the ``_id``
@@ -48,7 +48,8 @@ included automatically unless specifically excluded.
4848
client = Mongo::Client.new([ '127.0.0.1:27017' ], :database => 'test')
4949
collection = client[:restaurants]
5050

51-
collection.find({}, { 'name' => 1, 'cuisine' => 1 }).limit(5).each do |doc|
51+
collection.find({}, { 'projection' =>
52+
{ 'name' => 1, 'cuisine' => 1 } }).limit(5).each do |doc|
5253
p doc
5354
end
5455

@@ -57,11 +58,11 @@ including ``_id``, use the following projection document:
5758

5859
.. code-block:: javascript
5960

60-
{ 'name' : 1, 'cuisine' : 1, '_id': 0 }
61+
{ 'projection' => { 'name' => 1, 'cuisine' => 1, '_id' => 0 } }
6162

6263

6364
To return all fields *except* the address field, use the following:
6465

6566
.. code-block:: javascript
6667

67-
{ 'address' : 0 }
68+
{ 'projection' => { 'address' => 0 } }

0 commit comments

Comments
 (0)