Last active
August 29, 2015 14:24
-
-
Save dsaiztc/028bfcd6846785c2b019 to your computer and use it in GitHub Desktop.
Interactive JavaScript shell for MongoDB.
http://docs.mongodb.org/v2.2/mongo/
http://docs.mongodb.org/v2.2/reference/mongo-shell/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// cd <mongodb installation dir> | |
// ./bin/mongo | |
db // display database in use (default database: test) | |
show dbs // Show all databases | |
use <database> // select database to use | |
// Access a collection and use shell methods | |
show collections // show all collections for current database | |
db.<collection>.find() | |
db["3test"].find() | |
db.getCollection("3test").find() | |
db.<collection>.find().pretty() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# To run MongoDB just type: | |
mongod --dbpath ~/Development/MongoDB/db/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Import a JSON document | |
mongoimport -d dbname -c collectionname --file input-file.json | |
# Import a 'JSON Lines' document (one JSON document per file) into MongoDB http://jsonlines.org/ | |
mongoimport -d dbname -c collectionname --file input-file.jsonl | |
# Import a valid JSON document (in case we have several documents) | |
mongoimport --db <db-name> --collection <coll-name> --type json --file seed.json --jsonArray |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment