【正文】
isplays the current operation in the db () (func, args) run code serverside (ame) same as db[39。] or () () just returns the err msg string () return full status object () get the server connection object ().setSlaveOk() allow this connection to read from the nonmaster member of a replica pair () () () deprecated () returns if profiling is on and slow threshold () (name) get the db at the same server as this one () check replica primary status (opid) kills the current operation in the db () lists all the db mands () () () () (username) () () (cmdObj) run a database mand. if cmdObj is a string, turns it into { cmdObj : 1 } () (level,slowms) 0=off 1=slow 2=all () () () current version of the server ().setSlaveOk() allow queries on a replication slave server 對(duì)數(shù)據(jù)庫(kù)進(jìn)行管理和操作的基本命令,可以從上面獲取到。另一個(gè)比較基礎(chǔ)的是對(duì)指定數(shù)據(jù)庫(kù)的集合進(jìn)行操作、管理和監(jiān)控,()獲取到:[plain] view plaincopy () DBCollection help ().help() show DBCursor help () () ( key ) eg. ( 39。 ) () drop the collection (name) () (keypattern[,options]) options is an object with these possible fields: name, unique, dropDups () ([query],[fields]) query is an optional query filter. fields is optional set of fields to return. . ( {x:77} , {name:1, x:1} ) (...).count() (...).limit(n) (...).skip(n) (...).sort(...) ([query]) ( { update : ... , remove : bool [, query: {}, sort: {}, 39。: false] } ) () get DB object associated with collection () ( { key : ..., initial: ..., reduce : ...[, cond: ...] } ) ( mapFunction , reduceFunction , optional params ) (query) ( newName , dropTarget ) renames the collection. ( name , options ) runs a db mand with the given name where the first param is the collection name (obj) () () includes free space allocated to this collection () size in bytes of all the indexes () storage allocated for all data and indexes (query, object[, upsert_bool, multi_bool]) () SLOW () only for use with sharding 有關(guān)數(shù)據(jù)庫(kù)和集合管理的相關(guān)命令,是最基礎(chǔ)和最常用的,如集合查詢、索引操作等。示例如下所示:[plain] view plaincopy{ host : dev2, version : , process : mongod, uptime : 845446, uptimeEstimate : 839192, localTime : ISODate(20111227T04:03:), globalLock : { totalTime : 845445636925, lockTime : 13630973982, ratio : , currentQueue : { total : 0, readers : 0, writers : 0 }, activeClients : { total : 0, readers : 0, writers : 0 } }, mem : { bits : 64, resident : 12208, virtual : 466785, supported : true, mapped : 466139 }, connections : { current : 27, available : 792 }, extra_info : { note : fields vary by platform, heap_usage_bytes : 70895216, page_faults : 17213898 }, indexCounters : { btree : { accesses : 4466653, hits : 4465526, misses :