Skip to content

Commit d9536cd

Browse files
committed
edits
1 parent 96d5b2d commit d9536cd

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

source/includes/read/project.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
Mongo::Client.new(uri) do |client|
1111
# Access database and collection
1212
# start-db-coll
13-
database = client.database
14-
collection = client[:restaurants]
13+
database = client.use('sample_restaurants')
14+
collection = database[:restaurants]
1515
# end-db-coll
1616

1717
# Retrieves documents matching the "name" field query

source/read/project.txt

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@ of matching documents:
7777
.. output::
7878
:visible: false
7979

80-
{"_id": {"$oid": "..."}, "borough": "Manhattan", "cuisine": "American", "name": "Emerald Pub"}
81-
{"_id": {"$oid": "..."}, "borough": "Queens", "cuisine": "American", "name": "Emerald Pub"}
80+
{"_id"=>BSON::ObjectId('...'), "borough"=>"Manhattan", "cuisine"=>"American", "name"=>"Emerald Pub"}
81+
{"_id"=>BSON::ObjectId('...'), "borough"=>"Queens", "cuisine"=>"American", "name"=>"Emerald Pub"}
8282

8383
When you use a projection to specify fields to include in the return
8484
document, the ``_id`` field is also included by default. All other fields are
@@ -108,8 +108,8 @@ excludes the ``_id`` field from the projection:
108108
.. output::
109109
:visible: false
110110

111-
{"borough": "Manhattan", "cuisine": "American", "name": "Emerald Pub"}
112-
{"borough": "Queens", "cuisine": "American", "name": "Emerald Pub"}
111+
{"borough"=>"Manhattan", "cuisine"=>"American", "name"=>"Emerald Pub"}
112+
{"borough"=>"Queens", "cuisine"=>"American", "name"=>"Emerald Pub"}
113113

114114
Specify Fields to Exclude
115115
~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -139,10 +139,10 @@ in the result:
139139
.. output::
140140
:visible: false
141141

142-
{"_id": {"$oid": "..."}, "borough": "Manhattan", "cuisine": "American",
143-
"grades": [...], "restaurant_id": "40367329"}
144-
{"_id": {"$oid": "..."}, "borough": "Queens", "cuisine": "American",
145-
"grades": [...], "restaurant_id": "40668598"}
142+
{"_id"=>BSON::ObjectId('...'), "borough"=>"Manhattan", "cuisine"=>"American",
143+
"name"=>"Emerald Pub", "restaurant_id"=>"40367329"}
144+
{"_id"=>BSON::ObjectId('...'), "borough"=>"Queens", "cuisine"=>"American",
145+
"name"=>"Emerald Pub", "restaurant_id"=>"40668598"}
146146

147147
When you use a projection to specify which fields to exclude,
148148
any unspecified fields are implicitly included in the return document.

0 commit comments

Comments
 (0)