MongoDB usage notes (2)

Continuing prior notes from here.

Drop a database:

use databasename
db.dropDatabase()

List distinct property values across all docs:

db.collectionname.distict("propertyname")

Remove docs in a collection – param is a doc query. If empty doc, removes all docs:

db.collectionname.remove({})

Date range query using $gt and $lt for a range:

db.collectionname.find({ "timestamp" : { "$gte" : ISODate("2014-07-08T19:50"), "$lt" : ISODate("2014-07-08T19:52")  } })

[in progress]

Leave a Reply

Your email address will not be published. Required fields are marked *

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