|
Also the commands and JavaScript functions themselves have help associated with them. To see all of the operations that DBCollection supports you could do this:- > db.employees.help()
- DBCollection help
-
- db.employees.find().help() - show DBCursor help
- db.employees.count()
- db.employees.dataSize()
- db.employees.distinct( key ) - eg. db.employees.distinct( 'x' )
- db.employees.drop() drop the collection
- db.employees.dropIndex(name)
- db.employees.dropIndexes()
- db.employees.ensureIndex(keypattern[,options]) - options is an object with these possible fields: name, unique, dropDups
- db.employees.reIndex()
- db.employees.find([query],[fields]) - query is an optional query filter. fields is optional set of fields to return.
- e.g. db.employees.find( {x:77} , {name:1, x:1} )
- db.employees.find(...).count()
- db.employees.find(...).limit(n)
- db.employees.find(...).skip(n)
- db.employees.find(...).sort(...)
- db.employees.findOne([query])
- db.employees.findAndModify( { update : ... , remove : bool [, query: {}, sort: {}, 'new': false] } )
- db.employees.getDB() get DB object associated with collection
- db.employees.getIndexes()
- db.employees.group( { key : ..., initial: ..., reduce : ...[, cond: ...] } )
- db.employees.mapReduce( mapFunction , reduceFunction , {optional params=""} )
- db.employees.remove(query)
- db.employees.renameCollection( newName , {droptarget} ) renames the collection.
- db.employees.runCommand( name , {options} ) runs a db command with the given name where the first param is the collection name
- db.employees.save(obj)
- db.employees.stats()
- db.employees.storageSize() - includes free space allocated to this collection
- db.employees.totalIndexSize() - size in bytes of all the indexes
- db.employees.totalSize() - storage allocated for all data and indexes
- db.employees.update(query, object[, upsert_bool, multi_bool])
- db.employees.validate( {full} ) – SLOW
- db.employees.getShardVersion() - only for use with sharding
- db.employees.getShardDistribution() - prints statistics about data distribution in the cluster ...
复制代码 |
|