fasadak.blogg.se

Download mongodb collection as json
Download mongodb collection as json




download mongodb collection as json
  1. #Download mongodb collection as json how to
  2. #Download mongodb collection as json .exe

The above command will insert all data into employees collection, as shown below. If a file contains the header row that should be used as a field name then use -headerline option instead of -fields. The -fields option indicates the field names to be used for each column in the CSV file. D:\MyData> mongoimport -db test -collection employeesdata -type csv -file employees.csv -fields _id,firstName,lastName Note that -jsonArray indicates that the data in a file contains in an array.Ĭonsider that you have D:\employeesdata.csv file which you want to import into new employee collection.Įxecute the following command to import data from the CSV file. The above command will import data into the employees collection in the test database. Now, execute the following command to import data from D:\MyData\employeesdata.json file to employees collectionĭ:\MyData> mongoimport -db test -collection employees -file employeesdata.json -jsonArray authenticationDatabase admin -username -password ^ mongoimport -db database_name -collection collection_name ^ The following is the mongoimport command. Now, open the terminal or command prompt and navigate to the location where you have the JSON file to import so that you don't need to specify the whole path. On Windows, it is C:\Program Files\MongoDB\Server\\bin folder. Note that -jsonArray indicates that the data in a file contains in an array.

#Download mongodb collection as json .exe

exe files and paste them to the MongoDB bin folder. D:MyData> mongoimport -db test -collection employees -file employeesdata.json -jsonArray The above command will import data into the employees collection in the test database. To install the database tools, visit Database tools and download the zip file for your platform. You should have installed the MongoDB database tools to use the mongoimport command. Use mongoimport command to import data into a collection.

#Download mongodb collection as json how to

Here you are going to learn how to import JSON data or CSV file into a collection in MongoDB. Next Import Data in MongoDB using Mongoimport






Download mongodb collection as json