Mongo queries

To connect to mongo on the command-line:

mongo <database name>

 

To show the collections in the database:

show collections

 

To find documents in a collection:

db.collection.find()

eg

db.users.find()

 

To update documents:

db.collection.update()

eg

db.users.update({},{$set:{'country': 'NZ'}},{multi:true})

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.