mongoDB 幫助文檔

當登入到mongoDB 以後 能夠使用help 命令查看幫助文檔
系統級幫助文檔
> help
db.help() help on db methods # 數據庫級別幫助文檔
db.mycoll.help() help on collection methods # 集合級別幫助文檔
sh.help() sharding helpers # 關於分片的幫助文檔
rs.help() replica set helpers
help admin administrative help # 管理員幫助文檔
help connect connecting to a db help # 鏈接數據庫幫助文檔
help keys key shortcuts
help misc misc things to know
help mr mapreduce
 
show dbs show database names # 顯示數據庫
show collections show collections in current database # 顯示集合
show users show users in current database # 顯示用戶
show profile show most recent system.profile entries with time >= 1ms # 顯示profile
show logs show the accessible logger names # 顯示日誌(只是顯示有哪些日誌)
show log [name] prints out the last segment of log in memory, 'global' is default # 顯示指定日誌的內容
use <db_name> set current database # 切換到指定數據庫,若是不存在則默認建立
db.foo.find() list objects in collection foo # 查詢全部數據
db.foo.find( { a : 1 } ) list objects in foo where a == 1 # 查詢指定數據
it result of the last line evaluated; use to further iterate
DBQuery.shellBatchSize = x set default number of items to display on shell
exit quit the mongo shell
>
 
數據庫級別幫助文檔 使用db.數據庫名稱.help()
 
例如:
 
> db.mymongo.help()
DBCollection help
db.mymongo.find().help() - show DBCursor help # 查詢 幫助文檔
db.mymongo.bulkWrite( operations, <optional params> ) - bulk execute write operations, optional parameters are: w, wtimeout, j
db.mymongo.count( query = {}, <optional params> ) - count the number of documents that matches the query, optional parameters are: limit, skip, hint, maxTimeMS
db.mymongo.copyTo(newColl) - duplicates collection by copying all documents to newColl; no indexes are copied.
db.mymongo.convertToCapped(maxBytes) - calls {convertToCapped:'mymongo', size:maxBytes}} command
db.mymongo.createIndex(keypattern[,options])
db.mymongo.createIndexes([keypatterns], <options>)
db.mymongo.dataSize()
db.mymongo.deleteOne( filter, <optional params> ) - delete first matching document, optional parameters are: w, wtimeout, j
db.mymongo.deleteMany( filter, <optional params> ) - delete all matching documents, optional parameters are: w, wtimeout, j
db.mymongo.distinct( key, query, <optional params> ) - e.g. db.mymongo.distinct( 'x' ), optional parameters are: maxTimeMS
db.mymongo.drop() drop the collection
db.mymongo.dropIndex(index) - e.g. db.mymongo.dropIndex( "indexName" ) or db.mymongo.dropIndex( { "indexKey" : 1 } )
db.mymongo.dropIndexes()
db.mymongo.ensureIndex(keypattern[,options]) - DEPRECATED, use createIndex() instead
db.mymongo.explain().help() - show explain help
db.mymongo.reIndex()
db.mymongo.find([query],[fields]) - query is an optional query filter. fields is optional set of fields to return.
e.g. db.mymongo.find( {x:77} , {name:1, x:1} )
db.mymongo.find(...).count()
db.mymongo.find(...).limit(n)
db.mymongo.find(...).skip(n)
db.mymongo.find(...).sort(...)
db.mymongo.findOne([query], [fields], [options], [readConcern])
db.mymongo.findOneAndDelete( filter, <optional params> ) - delete first matching document, optional parameters are: projection, sort, maxTimeMS
db.mymongo.findOneAndReplace( filter, replacement, <optional params> ) - replace first matching document, optional parameters are: projection, sort, maxTimeMS, upsert, returnNewDocument
db.mymongo.findOneAndUpdate( filter, update, <optional params> ) - update first matching document, optional parameters are: projection, sort, maxTimeMS, upsert, returnNewDocument
db.mymongo.getDB() get DB object associated with collection
db.mymongo.getPlanCache() get query plan cache associated with collection
db.mymongo.getIndexes()
db.mymongo.group( { key : ..., initial: ..., reduce : ...[, cond: ...] } )
db.mymongo.insert(obj)
db.mymongo.insertOne( obj, <optional params> ) - insert a document, optional parameters are: w, wtimeout, j
db.mymongo.insertMany( [objects], <optional params> ) - insert multiple documents, optional parameters are: w, wtimeout, j
db.mymongo.mapReduce( mapFunction , reduceFunction , <optional params> )
db.mymongo.aggregate( [pipeline], <optional params> ) - performs an aggregation on a collection; returns a cursor
db.mymongo.remove(query)
db.mymongo.replaceOne( filter, replacement, <optional params> ) - replace the first matching document, optional parameters are: upsert, w, wtimeout, j
db.mymongo.renameCollection( newName , <dropTarget> ) renames the collection.
db.mymongo.runCommand( name , <options> ) runs a db command with the given name where the first param is the collection name
db.mymongo.save(obj)
db.mymongo.stats({scale: N, indexDetails: true/false, indexDetailsKey: <index key>, indexDetailsName: <index name>})
db.mymongo.storageSize() - includes free space allocated to this collection
db.mymongo.totalIndexSize() - size in bytes of all the indexes
db.mymongo.totalSize() - storage allocated for all data and indexes
db.mymongo.update( query, object[, upsert_bool, multi_bool] ) - instead of two flags, you can pass an object with fields: upsert, multi
db.mymongo.updateOne( filter, update, <optional params> ) - update the first matching document, optional parameters are: upsert, w, wtimeout, j
db.mymongo.updateMany( filter, update, <optional params> ) - update all matching documents, optional parameters are: upsert, w, wtimeout, j
db.mymongo.validate( <full> ) - SLOW
db.mymongo.getShardVersion() - only for use with sharding
db.mymongo.getShardDistribution() - prints statistics about data distribution in the cluster
db.mymongo.getSplitKeysForChunks( <maxChunkSize> ) - calculates split points over all chunks and returns splitter function
db.mymongo.getWriteConcern() - returns the write concern used for any operations on this collection, inherited from server/db if set
db.mymongo.setWriteConcern( <write concern doc> ) - sets the write concern for writes to the collection
db.mymongo.unsetWriteConcern( <write concern doc> ) - unsets the write concern for writes to the collection
 
表級別幫助文檔,使用db.表的名稱.help()
例如:
> db.noPK.help()
DBCollection help
db.noPK.find().help() - show DBCursor help
db.noPK.bulkWrite( operations, <optional params> ) - bulk execute write operations, optional parameters are: w, wtimeout, j
db.noPK.count( query = {}, <optional params> ) - count the number of documents that matches the query, optional parameters are: limit, skip, hint, maxTimeMS
db.noPK.copyTo(newColl) - duplicates collection by copying all documents to newColl; no indexes are copied.
db.noPK.convertToCapped(maxBytes) - calls {convertToCapped:'noPK', size:maxBytes}} command
db.noPK.createIndex(keypattern[,options])
db.noPK.createIndexes([keypatterns], <options>)
db.noPK.dataSize()
db.noPK.deleteOne( filter, <optional params> ) - delete first matching document, optional parameters are: w, wtimeout, j
db.noPK.deleteMany( filter, <optional params> ) - delete all matching documents, optional parameters are: w, wtimeout, j
db.noPK.distinct( key, query, <optional params> ) - e.g. db.noPK.distinct( 'x' ), optional parameters are: maxTimeMS
db.noPK.drop() drop the collection
db.noPK.dropIndex(index) - e.g. db.noPK.dropIndex( "indexName" ) or db.noPK.dropIndex( { "indexKey" : 1 } )
db.noPK.dropIndexes()
db.noPK.ensureIndex(keypattern[,options]) - DEPRECATED, use createIndex() instead
db.noPK.explain().help() - show explain help
db.noPK.reIndex()
db.noPK.find([query],[fields]) - query is an optional query filter. fields is optional set of fields to return.
e.g. db.noPK.find( {x:77} , {name:1, x:1} )
db.noPK.find(...).count()
db.noPK.find(...).limit(n)
db.noPK.find(...).skip(n)
db.noPK.find(...).sort(...)
db.noPK.findOne([query], [fields], [options], [readConcern])
db.noPK.findOneAndDelete( filter, <optional params> ) - delete first matching document, optional parameters are: projection, sort, maxTimeMS
db.noPK.findOneAndReplace( filter, replacement, <optional params> ) - replace first matching document, optional parameters are: projection, sort, maxTimeMS, upsert, returnNewDocument
db.noPK.findOneAndUpdate( filter, update, <optional params> ) - update first matching document, optional parameters are: projection, sort, maxTimeMS, upsert, returnNewDocument
db.noPK.getDB() get DB object associated with collection
db.noPK.getPlanCache() get query plan cache associated with collection
db.noPK.getIndexes()
db.noPK.group( { key : ..., initial: ..., reduce : ...[, cond: ...] } )
db.noPK.insert(obj)
db.noPK.insertOne( obj, <optional params> ) - insert a document, optional parameters are: w, wtimeout, j
db.noPK.insertMany( [objects], <optional params> ) - insert multiple documents, optional parameters are: w, wtimeout, j
db.noPK.mapReduce( mapFunction , reduceFunction , <optional params> )
db.noPK.aggregate( [pipeline], <optional params> ) - performs an aggregation on a collection; returns a cursor
db.noPK.remove(query)
db.noPK.replaceOne( filter, replacement, <optional params> ) - replace the first matching document, optional parameters are: upsert, w, wtimeout, j
db.noPK.renameCollection( newName , <dropTarget> ) renames the collection.
db.noPK.runCommand( name , <options> ) runs a db command with the given name where the first param is the collection name
db.noPK.save(obj)
db.noPK.stats({scale: N, indexDetails: true/false, indexDetailsKey: <index key>, indexDetailsName: <index name>})
db.noPK.storageSize() - includes free space allocated to this collection
db.noPK.totalIndexSize() - size in bytes of all the indexes
db.noPK.totalSize() - storage allocated for all data and indexes
db.noPK.update( query, object[, upsert_bool, multi_bool] ) - instead of two flags, you can pass an object with fields: upsert, multi
db.noPK.updateOne( filter, update, <optional params> ) - update the first matching document, optional parameters are: upsert, w, wtimeout, j
db.noPK.updateMany( filter, update, <optional params> ) - update all matching documents, optional parameters are: upsert, w, wtimeout, j
db.noPK.validate( <full> ) - SLOW
db.noPK.getShardVersion() - only for use with sharding
db.noPK.getShardDistribution() - prints statistics about data distribution in the cluster
db.noPK.getSplitKeysForChunks( <maxChunkSize> ) - calculates split points over all chunks and returns splitter function
db.noPK.getWriteConcern() - returns the write concern used for any operations on this collection, inherited from server/db if set
db.noPK.setWriteConcern( <write concern doc> ) - sets the write concern for writes to the collection
db.noPK.unsetWriteConcern( <write concern doc> ) - unsets the write concern for writes to the collection
>
相關文章
相關標籤/搜索