The restaurants.json dataset contains 10 documents of the form:
{
"_id" : <ObjectId>,
"name" : <string>,
"contact" : {
"phone" : <string>
"email" : <string>
"location" : [ <longitude>, <latitude> ]
},
"stars" : int,
"categories" : <array of strings>
"grades" : <array of integers>,
}
Note: The MongoDB deployment to which you wish to import the data must be running.
Download and save the restaurants.json dataset.
In the terminal shell or command prompt, use
mongoimport
(ormongoimport.exe
on Windows) to insert the documents. For example, the followingmongoimport
connects to amongod
instance running on localhost on port number27017
.mongoimport --db test --collection restaurants --drop --file <path to saved file>
Note: If
mongoimport
is not in your path, either update the path or specify the full path to the executable.To import to a MongoDB deployment running on a different host or port, specify
--host
and--port
options in your mongoimport command. See mongoimport for details on available options.