Skip to content

Commit 7cf97e2

Browse files
committed
Add restaurants.json to example data documentation
1 parent c6c000b commit 7cf97e2

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

docs/tutorial/example-data.txt

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,25 @@ Example Data
55
.. default-domain:: mongodb
66

77
Some examples in this documentation use example data fixtures from
8-
`zips.json <http://media.mongodb.org/zips.json>`_. This is a dataset comprised
9-
of United States postal codes, populations, and geographic locations.
8+
`zips.json <https://media.mongodb.org/zips.json>`_ and
9+
`primer-dataset.json <https://raw.githubusercontent.com/mongodb/docs-assets/primer-dataset/primer-dataset.json>`_.
1010

1111
Importing the dataset into MongoDB can be done in several ways. The following
12-
example uses the :php:`driver <mongodb>` directly:
12+
example imports the `zips.json` file into a `demo.zips` collection:
13+
:php:`driver <mongodb>` directly:
1314

1415
.. code-block:: php
1516

1617
<?php
1718

18-
$file = 'http://media.mongodb.org/zips.json';
19-
$zips = file($file, FILE_IGNORE_NEW_LINES);
19+
$filename = 'https://media.mongodb.org/zips.json';
20+
$lines = file($filename, FILE_IGNORE_NEW_LINES);
2021

2122
$bulk = new MongoDB\Driver\BulkWrite;
2223

23-
foreach ($zips as $string) {
24-
$document = json_decode($string);
24+
foreach ($lines as $line) {
25+
$bson = MongoDB\BSON\fromJSON($line);
26+
$document = MongoDB\BSON\toPHP($bson);
2527
$bulk->insert($document);
2628
}
2729

@@ -34,9 +36,10 @@ The output would then resemble::
3436

3537
Inserted 29353 documents
3638

37-
You may also import the dataset using :manual:`mongoimport
39+
You may also import the datasets using :manual:`mongoimport
3840
</reference/program/mongoimport>`, which is included with MongoDB:
3941

4042
.. code-block:: none
4143

4244
$ mongoimport --db demo --collection zips --file zips.json --drop
45+
$ mongoimport --db demo --collection restaurants --file primer-dataset.json --drop

0 commit comments

Comments
 (0)