1
+ title : Download the ``restaurants`` data.
2
+ ref : " primer-data-download"
3
+ edition :
4
+ - shell
5
+ - python
6
+ - node
7
+ content : " Download data <link>."
8
+ ---
9
+ title : Import data into the collection.
10
+ ref : " primer-data-import"
11
+ pre : |
12
+ In the system shell or command prompt, use ``mongoimport`` to insert
13
+ the documents into the ``restaurants`` collection in the ``test``
14
+ database. The operation will **drop** the ``restaurants`` collection
15
+ first, if it already exists.
16
+ action :
17
+ language : javascript
18
+ code : |
19
+ mongoimport --db test --collection restaurants --drop --file "dataset.2015-01-20/dataset.json"
20
+ edition :
21
+ - shell
22
+ - python
23
+ ---
24
+ title : Switch to ``test`` database.
25
+ ref : " primer-prereq-switch-db-shell"
26
+ edition : shell
27
+ pre : |
28
+ In the ``mongo`` shell connected to a running :program:`mongod`
29
+ instance, switch to the ``test`` database.
30
+ action :
31
+ language : javascript
32
+ code : |
33
+ use test
34
+ ---
35
+ title : Switch to ``test`` database.
36
+ ref : " primer-prereq-switch-db-python"
37
+ edition : python
38
+ pre : |
39
+ From a Python Shell or IDLE, use
40
+ :py:class:`~pymongo.mongo_client.MongoClient()` to connect to the
41
+ running :program:`mongod` instance, and switch to the ``test``
42
+ database.
43
+ action :
44
+ language : python
45
+ code : |
46
+ from pymongo import MongoClient
47
+ client = MongoClient()
48
+ db = client.test
49
+ ---
50
+ title : Define required variables.
51
+ ref : " primer-prereq-switch-db-node"
52
+ edition : node
53
+ pre : |
54
+ From a ``node`` shell, define the following variables to
55
+ access the required modules as well as to initialize ``url`` to the
56
+ :manual:`MongoDB uri </reference/connection-string>`.
57
+ action :
58
+ language : javascript
59
+ code : |
60
+ var MongoClient = require('mongodb').MongoClient
61
+ var assert = require('assert')
62
+ var util = require('util').format;
63
+ var url = 'mongodb://localhost:27017/test';
64
+ ...
0 commit comments