Basic cheat sheet for mongo

Export data

DATABASE=foo
COLLECTION=foo
OUT=foo.json
mongoexport --db $DATABASE --collection $COLLECTION --out $OUT

Import Data

INPUT=foo.json
mongoimport --db places --collection places --drop --file $INPUT

Basic commands

# list available datababases
show dbs;
# use a database
use db_name;
# simple query
db.collection_name.find().limit(1).pretty()
# create index
db.collection_name.createIndex({field:1})