thefourtheye's weblog

opinions are my own; try code/suggestions at your own risk

MongoDB Miscellaneous

| Comments

Querying based on Date & Time
   db.[Colletion].find ({Date:ISODate('2013-04-22T00:00:00Z')})

Equivalent of Oracle's Count function
   db.[Collection].find ({'FieldName':'value').length

Find distinct values of a column, after Querying
   db.[Collection].distinct ('ColumnName', {'SearchColumnName' : 'SearchValue'})

Number of distinct values
   db.[Collection].distinct ('ColumnName').length

Sorting the returned result with pymongo

db.[Collection].find().sort (
[
("FieldName1", pymongo.DESCENDING),
("FieldName2", pymongo.DESCENDING),
("FieldName3", pymongo.ASCENDING),
])