@@ -26,7 +26,7 @@ following form:
26
26
27
27
.. code-block:: javascript
28
28
29
- { field1: <value>, field2: <value> ... }
29
+ { 'projection': { field1: <value>, field2: <value> ... } }
30
30
31
31
``<value>`` may be ``0`` (or ``false``) to exclude the field, or
32
32
``1`` (or ``true``) to include it. With the exception of the ``_id``
@@ -48,7 +48,8 @@ included automatically unless specifically excluded.
48
48
client = Mongo::Client.new([ '127.0.0.1:27017' ], :database => 'test')
49
49
collection = client[:restaurants]
50
50
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|
52
53
p doc
53
54
end
54
55
@@ -57,11 +58,11 @@ including ``_id``, use the following projection document:
57
58
58
59
.. code-block:: javascript
59
60
60
- { 'name' : 1, 'cuisine' : 1, '_id': 0 }
61
+ { 'projection' => { ' name' => 1, 'cuisine' => 1, '_id' => 0 } }
61
62
62
63
63
64
To return all fields *except* the address field, use the following:
64
65
65
66
.. code-block:: javascript
66
67
67
- { 'address' : 0 }
68
+ { 'projection' => { ' address' => 0 } }
0 commit comments