Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.