Skip to content

Instantly share code, notes, and snippets.

@celestelayne
Last active August 29, 2015 14:27
Show Gist options
  • Save celestelayne/039c9f094e7ded667aef to your computer and use it in GitHub Desktop.
Save celestelayne/039c9f094e7ded667aef to your computer and use it in GitHub Desktop.
Import JSON to MongoDB

*** Using mongoimport

mongoimport --db artmapr --collection arts --type json --file models/sf_data.json --jsonArray

  • cd /usr/local
  • RUN mongod (in separate terminal window)
  • ./bin/mongo
  • db

  • show dbs (lists all databases)
  • use artmapr (switches to artmapr database)

Here are THREE options to load data into MongoDB:

Client side: Angular level Automate lots of user inputs Server side: Nodejs + Express + Mongoose Define the schema in Mongoose, create the objects, save each one Database side: Mongodb Make a json file with the data, and import it directly into Mongo: mongoimport -d db_name -c collection_name --jsonArray --file jsonfilename.json

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment