-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathimport-data.txt
More file actions
27 lines (27 loc) · 926 Bytes
/
import-data.txt
File metadata and controls
27 lines (27 loc) · 926 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
## instructions for importing data into a mongodb database from a json file
## requirements/installations: (Mongodb)
1- the valid format of the json file should be like this
(this is a books collection as an example)
############################################
{
"title":"War and Peace",
"genre":"Historical Fiction",
"author":"Lev Nikolayevich Tolstoy",
"read":false
}
{
"title":"Les Misérables",
"genre":"Historical Fiction",
"author":"Victor Hugo",
"read":false
}
############################################
2- type the following command in terminal
and replace the DB name and the file name and location
with your names
mongoimport --db bookAPI --collection books --drop --file /var/www/levelupWorkspace/nodejs/BookAPI/books.json
## references
1- json valid format (second answer of user Alex Glukhovtsev)
https://goo.gl/mg2UCd
2- import json collection to mongodb database command
https://goo.gl/xSIJV2