Skip to content

Instantly share code, notes, and snippets.

@leommoore
Last active October 8, 2015 07:38
Show Gist options
  • Select an option

  • Save leommoore/3299752 to your computer and use it in GitHub Desktop.

Select an option

Save leommoore/3299752 to your computer and use it in GitHub Desktop.
MongoDB Basics

#MongoDB Basics

This is a really useful link to update the default mongodb updated to the latest version

http://askubuntu.com/questions/147135/how-can-i-uninstall-mongodb-and-reinstall-the-latest-version

Basic Commands:

db.help()                    help on db methods
db.mycoll.help()             help on collection methods
rs.help()                    help on replica set methods
help admin                   administrative help
help connect                 connecting to a db help
help keys                    key shortcuts
help misc                    misc things to know
help mr                      mapreduce

show dbs                     show database names
show collections             show collections in current database
show users                   show users in current database
show profile                 show most recent system.profile entries with time >= 1ms
show logs                    show the accessible logger names
show log [name]              prints out the last segment of log in memory, 'global' is default
use <db_name>                set current database
db.foo.find()                list objects in collection foo
db.foo.find( { a : 1 } )     list objects in foo where a == 1
it                           result of the last line evaluated; use to further iterate
DBQuery.shellBatchSize = x   set default number of items to display on shell
exit                         quit the mongo shell
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment