MongoDB Distinct

摘要:MongoDB Distinct

http://docs.mongodb.org/manual/reference/command/distinct/

 

 

db.runCommand ( { distinct: 'orders',
                  key: 'ord_dt',
                  query: { price: { $gt: 10 } }
                } )

ex.

use RockMongo / database  / 命令 

{ "distinct": "collection_name", "key": "field1_name", "query":{"field1_name":"field_value" } }

 

Response from server :

{
   "values": [
     "field_value1",

     "field_value2"
  ],
   "stats": {
     "n": NumberInt(70),
     "nscanned": NumberInt(2223),
     "nscannedObjects": NumberInt(2223),
     "timems": NumberInt(3),
     "cursor": "BasicCursor" 
  },
   "ok": 1 
}

 

延申參考 - Group

http://docs.mongodb.org/manual/reference/command/group/