Skip to content

Commit 37689c6

Browse files
authored
DOCSP-24243 adding insert operations to airports example (#1672) (#1682)
* DOCSP-24243 adding insert operations to airports example * DOCSP-24243 small fixes
1 parent 0bf14f0 commit 37689c6

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
@@ -336,25 +336,30 @@ Across Multiple Collections
336336
Like :pipeline:`$lookup`, :pipeline:`$graphLookup` can access
337337
another collection in the same database.
338338

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

341-
- A collection ``airports`` with the following documents:
341+
- An ``airports`` collection with the following documents:
342342

343343
.. code-block:: javascript
344344

345-
{ "_id" : 0, "airport" : "JFK", "connects" : [ "BOS", "ORD" ] }
346-
{ "_id" : 1, "airport" : "BOS", "connects" : [ "JFK", "PWM" ] }
347-
{ "_id" : 2, "airport" : "ORD", "connects" : [ "JFK" ] }
348-
{ "_id" : 3, "airport" : "PWM", "connects" : [ "BOS", "LHR" ] }
349-
{ "_id" : 4, "airport" : "LHR", "connects" : [ "PWM" ] }
345+
db.airports.insertMany( [
346+
{ "_id" : 0, "airport" : "JFK", "connects" : [ "BOS", "ORD" ] },
347+
{ "_id" : 1, "airport" : "BOS", "connects" : [ "JFK", "PWM" ] },
348+
{ "_id" : 2, "airport" : "ORD", "connects" : [ "JFK" ] },
349+
{ "_id" : 3, "airport" : "PWM", "connects" : [ "BOS", "LHR" ] },
350+
{ "_id" : 4, "airport" : "LHR", "connects" : [ "PWM" ] }
351+
] )
350352

351-
- A collection ``travelers`` with the following documents:
353+
- A ``travelers`` collection with the following documents:
352354

353355
.. code-block:: javascript
354356

355-
{ "_id" : 1, "name" : "Dev", "nearestAirport" : "JFK" }
356-
{ "_id" : 2, "name" : "Eliot", "nearestAirport" : "JFK" }
357-
{ "_id" : 3, "name" : "Jeff", "nearestAirport" : "BOS" }
357+
db.travelers.insertMany( [
358+
{ "_id" : 1, "name" : "Dev", "nearestAirport" : "JFK" },
359+
{ "_id" : 2, "name" : "Eliot", "nearestAirport" : "JFK" },
360+
{ "_id" : 3, "name" : "Jeff", "nearestAirport" : "BOS" }
361+
] )
362+
358363

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

0 commit comments

Comments
 (0)