MongoDB: db.listCommands() method
db.listCommands
The db.listCommands() method is used to display a list of common database commands.
Syntax:
db.listCommands()
Example: MongoDB: db.listCommands() method
db.listCommands();
Output:
> db.listCommands(); _isSelf: { _isSelf : 1 } INTERNAL ONLY _mergeAuthzCollections: adminOnly slaveOk Internal command used by mongorestore for updating user/role data _migrateClone: adminOnly slaveOk internal _recvChunkAbort: adminOnly slaveOk internal _recvChunkCommit: adminOnly slaveOk internal _recvChunkStart: adminOnly slaveOk internal _recvChunkStatus: adminOnly slaveOk internal _transferMods: adminOnly slaveOk internal aggregate: { pipeline: [ { $operator: {...}}, ... ], explain: <bool>, allowDiskUse: <bool>, cursor: {batchSize: <number>} } See http://dochub.mongodb.org/core/aggregation for more details. appendOplogNote: adminOnly slaveOk Adds a no-op entry to the oplog applyOps: internal (sharding) { applyOps : [ ] , preCondition : [ { ns : ... , q : ... , res : ... } ] } authSchemaUpgrade: adminOnly slaveOk Upgrades the auth data storage schema authenticate: internal availableQueryOptions: no help defined buildInfo: get version #, etc. { buildinfo:1 } checkShardingIndex: Internal command. cleanupOrphaned: adminOnly slaveOk no help defined clone: clone this database from an instance of the db on another host { clone : "host13" } cloneCollection: { cloneCollection: <collection>, from: <host> [,query: <query_filter>] [,copyIndexes:<bool>] } Copies a collection from one server to another. Do not use on a single server as the destination is placed at the same db.collection (namespace) as the source. cloneCollectionAsCapped: { cloneCollectionAsCapped:<fromName>, toCollection:<toName>, size:<sizeInBytes> } closeAllDatabases: adminOnly slaveOk Close all database files. A new request will cause an immediate reopening; thus, this is mostly for testing purposes. collMod: Sets collection options. Example: { collMod: 'foo', usePowerOf2Sizes:true } Example: { collMod: 'foo', index: {keyPattern: {a: 1}, expireAfterSeconds: 600} } collStats: { collStats:"blog.posts" , scale : 1 } scale divides sizes e.g. for KB use 1024 avgObjSize - in bytes compact: compact collection warning: this operation locks the database and is slow. you can cancel with killOp() { compact : <collection_name>, [force:<bool>], [validate:<bool>], [paddingFactor:<num>], [paddingBytes:<num>] } force - allows to run on a replica set primary validate - check records are noncorrupt before adding to newly compacting extents. slower but safer (defaults to true in this version) connPoolStats: stats about connection pool connPoolSync: internal connectionStatus: Returns connection-specific information such as logged-in users convertToCapped: { convertToCapped:<fromCollectionName>, size:<sizeInBytes> } copydb: adminOnly slaveOk copy a database from another host to this host usage: {copydb: 1, fromhost: <connection string>, fromdb: <db>, todb: <db>[, slaveOk: <bool>, username: <username>, nonce: <nonce>, key: <key>]} copydbgetnonce: adminOnly slaveOk get a nonce for subsequent copy db request from secure server usage: {copydbgetnonce: 1, fromhost: <hostname>} count: count objects in collection create: create a collection explicitly { create: <ns>[, capped: <bool>, size: <collSizeInBytes>, max: <nDocs>] } createIndexes: no help defined createRole: Adds a role to the system createUser: Adds a user to the system cursorInfo: example: { cursorInfo : 1 }, deprecated dataSize: determine data size for a set of data in a certain range example: { dataSize:"blog.posts", keyPattern:{x:1}, min:{x:10}, max:{x:55} } min and max parameters are optional. They must either both be included or both omitted keyPattern is an optional parameter indicating an index pattern that would be usefulfor iterating over the min/max bounds. If keyPattern is omitted, it is inferred from the structure of min. note: This command may take a while to run dbHash: no help defined dbStats: Get stats on a database. Not instantaneous. Slower for databases with large .ns files. Example: { dbStats:1, scale:1 } delete: delete documents diagLogging: adminOnly slaveOk http://dochub.mongodb.org/core/monitoring#MonitoringandDiagnostics-DatabaseRecord%2FReplay%28diagLoggingcommand%29 distinct: { distinct : 'collection name' , key : 'a.b' , query : {} } driverOIDTest: no help defined drop: drop a collection {drop : <collectionName>} dropAllRolesFromDatabase: Drops all roles from the given database. Before deleting the roles completely it must remove them from any users or other roles that reference them. If any errors occur in the middle of that process it's possible to be left in a state where the roles have been removed from some user/roles but ot herwise still exist. dropAllUsersFromDatabase: Drops all users for a single database. dropDatabase: drop (delete) this database dropIndexes: drop indexes for a collection dropRole: Drops a single role. Before deleting the role completely it must remove it from any users or roles that reference it. If any errors occur in the middle of that process it's possible to be left in a state where the role has been removed from some user/roles but otherwise still exists. dropUser: Drops a single user. eval: Evaluate javascript at the server. http://dochub.mongodb.org/core/serversidecodeexecution features: return build level feature settings filemd5: example: { filemd5 : ObjectId(aaaaaaa) , root : "fs" } findAndModify: { findAndModify: "collection", query: {processed:false}, update: {$set: {processed:true}}, new: true} { findAndModify: "collection", query: {processed:false}, remove: true, sort: {priority:-1}} Either update or remove is required, all other fields have default values. Output is in the "value" field forceerror: for testing purposes only. forces a user assertion exception fsync: adminOnly slaveOk http://dochub.mongodb.org/core/fsynccommand geoNear: http://dochub.mongodb.org/core/geo#GeospatialIndexing-geoNearCommand geoSearch: no help defined getCmdLineOpts: adminOnly slaveOk get argv getLastError: return error status of the last operation on this connection options: { fsync:true } - fsync before returning, or wait for journal commit if running with --journal { j:true } - wait for journal commit if running with --journal { w:n } - await replication to n servers (including self) before returning { w:'majority' } - await replication to majority of set { wtimeout:m} - timeout for w in m milliseconds getLog: adminOnly slaveOk { getLog : '*' } OR { getLog : 'global' } getParameter: adminOnly slaveOk get administrative option(s) example: { getParameter:1, notablescan:1 } supported: _forceLegacyShardWriteMode authSchemaVersion clusterAuthMode connPoolMaxConnsPerHost connPoolMaxShardedConnsPerHost enableLocalhostAuthBypass enableTestCommands failIndexKeyTooLong internalQueryCacheFeedbacksStored internalQueryCacheSize internalQueryCacheStdDeviations internalQueryCacheWriteOpsBetweenFlush internalQueryEnumerationMaxIntersectPerAnd internalQueryEnumerationMaxOrSolutions internalQueryForceIntersectionPlans internalQueryMaxScansToExplode internalQueryPlanEvaluationCollFraction internalQueryPlanEvaluationMaxResults internalQueryPlanEvaluationWorks internalQueryPlanOrChildrenIndependently internalQueryPlannerEnableHashIntersection internalQueryPlannerEnableIndexIntersection internalQueryPlannerMaxIndexedSolutions internalSCCAllowFastestAuthConfigReads internalSCCAllowFastestMetadataConfigReads logLevel logUserIds maxSyncSourceLagSecs newCollectionsUsePowerOf2Sizes notablescan queueForMigrationCommit quiet releaseConnectionsAfterResponse replApplyBatchSize replIndexPrefetch sslMode supportCompatibilityFormPrivilegeDocuments syncdelay textSearchEnabled ttlMonitorEnabled verboseQueryLogging { getParameter:'*' } to get everything getPrevError: check for errors since last reseterror commandcal getShardMap: adminOnly slaveOk internal getShardVersion: adminOnly slaveOk example: { getShardVersion : 'alleyinsider.foo' } getnonce: internal getoptime: internal grantPrivilegesToRole: Grants privileges to a role grantRolesToRole: Grants roles to another role. grantRolesToUser: Grants roles to a user. group: http://dochub.mongodb.org/core/aggregation handshake: internal hostInfo: returns information about the daemon's host insert: insert documents invalidateUserCache: Invalidates the in-memory cache of user information isMaster: Check if this server is primary for a replica pair/set; also if it is --master or --slave in simple master/slave setups. { isMaster : 1 } listCommands: get a list of all db commands listDatabases: adminOnly slaveOk list databases on this server logRotate: adminOnly slaveOk no help defined logout: de-authenticate mapReduce: Run a map/reduce operation on the server. Note this is used for aggregation, not querying, in MongoDB. http://dochub.mongodb.org/core/mapreduce mapreduce.shardedfinish: internal medianKey: Deprecated internal command. Use splitVector command instead. mergeChunks: adminOnly slaveOk Merge Chunks command usage: { mergeChunks : <ns>, bounds : [ <min key>, <max key> ], (opt) epoch : <epoch>, (opt) config : <configdb string>, (opt) shardName : <shard name> } moveChunk: adminOnly slaveOk should not be calling this directly parallelCollectionScan: no help defined ping: a way to check that the server is alive. responds immediately even if server is in a db lock. planCacheClear: Drops one or all cached queries in a collection. planCacheClearFilters: Clears index filter for a single query shape or, if the query shape is omitted, all filters for the collection. planCacheListFilters: Displays index filters for all query shapes in a collection. planCacheListPlans: Displays the cached plans for a query shape. planCacheListQueryShapes: Displays all query shapes in a collection. planCacheSetFilter: Sets index filter for a query shape. Overrides existing filter. profile: enable or disable performance profiling { profile : <n> } 0=off 1=log slow ops 2=log all -1 to get current values http://dochub.mongodb.org/core/databaseprofiler reIndex: re-index a collection renameCollection: adminOnly slaveOk example: { renameCollection: foo.a, to: bar.b } repairDatabase: repair database. also compacts. note: slow. replSetElect: adminOnly slaveOk internal replSetFreeze: adminOnly slaveOk { replSetFreeze : <seconds> }'freeze' state of member to the extent we can do that. What this really means is that this node will not attempt to become primary until the time period specified expires. You can call again with {replSetFreeze:0} to unfreeze sooner. A process restart unfreezes the member also. http://dochub.mongodb.org/core/replicasetcommands replSetFresh: adminOnly slaveOk internal replSetGetRBID: adminOnly slaveOk internal replSetGetStatus: adminOnly slaveOk Report status of a replica set from the POV of this server { replSetGetStatus : 1 } http://dochub.mongodb.org/core/replicasetcommands replSetHeartbeat: adminOnly slaveOk internal replSetInitiate: adminOnly slaveOk Initiate/christen a replica set. http://dochub.mongodb.org/core/replicasetcommands replSetMaintenance: adminOnly slaveOk { replSetMaintenance : bool } Enable or disable maintenance mode. replSetReconfig: adminOnly slaveOk Adjust configuration of a replica set { replSetReconfig : config_object } http://dochub.mongodb.org/core/replicasetcommands replSetStepDown: adminOnly slaveOk { replSetStepDown : <seconds> } Step down as primary. Will not try to reelect self for the specified time period (1 minute if no numeric secs value specified). (If another member with same priority takes over in the meantime, it will stay primary.) http://dochub.mongodb.org/core/replicasetcommands replSetSyncFrom: adminOnly slaveOk { replSetSyncFrom : "host:port" } Change who this member is syncing from. replSetUpdatePosition: adminOnly slaveOk internal resetError: reset error state (used with getpreverror) resync: adminOnly slaveOk resync (from scratch) a stale slave or replica set secondary node. revokePrivilegesFromRole: Revokes privileges from a role revokeRolesFromRole: Revokes roles from another role. revokeRolesFromUser: Revokes roles from a user. rolesInfo: Returns information about roles. serverStatus: returns lots of administrative server statistics setParameter: adminOnly slaveOk set administrative option(s) { setParameter:1, <param>:<value> } supported: _forceLegacyShardWriteMode authSchemaVersion clusterAuthMode connPoolMaxConnsPerHost connPoolMaxShardedConnsPerHost enableLocalhostAuthBypass enableTestCommands failIndexKeyTooLong internalQueryCacheFeedbacksStored internalQueryCacheSize internalQueryCacheStdDeviations internalQueryCacheWriteOpsBetweenFlush internalQueryEnumerationMaxIntersectPerAnd internalQueryEnumerationMaxOrSolutions internalQueryForceIntersectionPlans internalQueryMaxScansToExplode internalQueryPlanEvaluationCollFraction internalQueryPlanEvaluationMaxResults internalQueryPlanEvaluationWorks internalQueryPlanOrChildrenIndependently internalQueryPlannerEnableHashIntersection internalQueryPlannerEnableIndexIntersection internalQueryPlannerMaxIndexedSolutions internalSCCAllowFastestAuthConfigReads internalSCCAllowFastestMetadataConfigReads logLevel logUserIds maxSyncSourceLagSecs newCollectionsUsePowerOf2Sizes notablescan queueForMigrationCommit quiet releaseConnectionsAfterResponse replApplyBatchSize replIndexPrefetch sslMode supportCompatibilityFormPrivilegeDocuments syncdelay textSearchEnabled ttlMonitorEnabled verboseQueryLogging setShardVersion: adminOnly slaveOk internal shardConnPoolStats: stats about the shard connection pool shardingState: adminOnly slaveOk no help defined shutdown: adminOnly slaveOk shutdown the database. must be ran against admin db and either (1) ran from localhost or (2) authenticated. If this is a primary in a replica set and there is no member within 10 seconds of its optime, it will not shutdown without force : true. You can also specify timeoutSecs : N to wait N seco nds for other members to catch up. splitChunk: adminOnly slaveOk internal command usage only example: { splitChunk:"db.foo" , keyPattern: {a:1} , min : {a:100} , max: {a:200} { splitKeys : [ {a:150} , ... ]} splitVector: Internal command. examples: { splitVector : "blog.post" , keyPattern:{x:1} , min:{x:10} , max:{x:20}, maxChunkSize:200 } maxChunkSize unit in MBs May optionally specify 'maxSplitPoints' and 'maxChunkObjects' to avoid traversing the whole chunk { splitVector : "blog.post" , keyPattern:{x:1} , min:{x:10} , max:{x:20}, force: true } 'force' will produce one split point even if data is small; defaults to false NOTE: This command may take a while to run stageDebug: text: no help defined top: adminOnly slaveOk usage by collection, in micros touch: touch collection Page in all pages of memory containing every extent for the given collection { touch : <collection_name>, [data : true] , [index : true] } at least one of data or index must be true; default is both are false unsetSharding: adminOnly slaveOk internal update: update documents updateRole: Used to update a role updateUser: Used to update a user, for example to change its password usersInfo: Returns information about users. validate: Validate contents of a namespace by scanning its data structures for correctness. Slow. Add full:true option to do a more thorough check whatsmyuri: {whatsmyuri:1} writeBacksQueued: adminOnly slaveOk internal writebacklisten: adminOnly slaveOk internal
Retrieve the restaurants data from here
Previous:
db.isMaster() method
Next:
db.logout() method
It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.
https://w3resource.com/mongodb/shell-methods/database/db-listCommands.php
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics