Skip to content

Instantly share code, notes, and snippets.

@PythonicNinja
Created October 3, 2014 11:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save PythonicNinja/ba62dcfc62f7fe3f3856 to your computer and use it in GitHub Desktop.
Save PythonicNinja/ba62dcfc62f7fe3f3856 to your computer and use it in GitHub Desktop.
mongodb commands
mongod --path
mkdir -p /data/db
db.help()
-- shows databases
show dbs
-- shows collections
show collections
-- delete
db.canada.drop()
-- change databse
use xxx
-- inserts
db.jobes.insert({text: "Hi!"});
db.jobes.insert({text: "Hej!", stars: -1});
-- query
db.jobes.find()
db.jobes.findOne()
db.jobes.find({text: /!$/})
db.jobes.find({province: "BC"}).count()
db.jobes.find({province: "BC"}).explain()
-- delete
db.jobes.
-- import
mongoimport --help
mongoimport --type csv --headerline doc/CSV/products/breuninger_july_complete_utf8.csv -c products
-- export
mongoexport -c products > products.json
head -l products.json | jq
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment