Skip to content

Commit 28099d3

Browse files
authored
DOCSP-24243 adding insert operations to airports example (#1672)
* DOCSP-24243 adding insert operations to airports example * DOCSP-24243 small fixes
1 parent e3f3617 commit 28099d3

File tree

1 file changed

+16
-11
lines changed

1 file changed

+16
-11
lines changed

source/reference/operator/aggregation/graphLookup.txt

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -317,25 +317,30 @@ Across Multiple Collections
317317
Like :pipeline:`$lookup`, :pipeline:`$graphLookup` can access
318318
another collection in the same database.
319319

320-
In the following example, a database contains two collections:
320+
For example, create a database with two collections:
321321

322-
- A collection ``airports`` with the following documents:
322+
- An ``airports`` collection with the following documents:
323323

324324
.. code-block:: javascript
325325

326-
{ "_id" : 0, "airport" : "JFK", "connects" : [ "BOS", "ORD" ] }
327-
{ "_id" : 1, "airport" : "BOS", "connects" : [ "JFK", "PWM" ] }
328-
{ "_id" : 2, "airport" : "ORD", "connects" : [ "JFK" ] }
329-
{ "_id" : 3, "airport" : "PWM", "connects" : [ "BOS", "LHR" ] }
330-
{ "_id" : 4, "airport" : "LHR", "connects" : [ "PWM" ] }
326+
db.airports.insertMany( [
327+
{ "_id" : 0, "airport" : "JFK", "connects" : [ "BOS", "ORD" ] },
328+
{ "_id" : 1, "airport" : "BOS", "connects" : [ "JFK", "PWM" ] },
329+
{ "_id" : 2, "airport" : "ORD", "connects" : [ "JFK" ] },
330+
{ "_id" : 3, "airport" : "PWM", "connects" : [ "BOS", "LHR" ] },
331+
{ "_id" : 4, "airport" : "LHR", "connects" : [ "PWM" ] }
332+
] )
331333

332-
- A collection ``travelers`` with the following documents:
334+
- A ``travelers`` collection with the following documents:
333335

334336
.. code-block:: javascript
335337

336-
{ "_id" : 1, "name" : "Dev", "nearestAirport" : "JFK" }
337-
{ "_id" : 2, "name" : "Eliot", "nearestAirport" : "JFK" }
338-
{ "_id" : 3, "name" : "Jeff", "nearestAirport" : "BOS" }
338+
db.travelers.insertMany( [
339+
{ "_id" : 1, "name" : "Dev", "nearestAirport" : "JFK" },
340+
{ "_id" : 2, "name" : "Eliot", "nearestAirport" : "JFK" },
341+
{ "_id" : 3, "name" : "Jeff", "nearestAirport" : "BOS" }
342+
] )
343+
339344

340345
For each document in the ``travelers`` collection, the following
341346
aggregation operation looks up the ``nearestAirport`` value in the

0 commit comments

Comments
 (0)