This method returns text output listing common methods on the db object.
Syntax:
db.help()
Example
MongoDB
db.help()
Output:
DB methods:db.adminCommand(nameOrDocument) - switches to 'admin' db, and runs command [just calls db.runCommand(...)]db.aggregate([pipeline], {options}) - performs a collectionless aggregation on this database; returns a cursordb.auth(username, password)db.commandHelp(name) returns the help for the commanddb.createUser(userDocument)db.createView(name, viewOn, [{$operator: {...}}, ...], {viewOptions})db.currentOp() displays currently executing operations in the dbdb.dropDatabase(writeConcern)db.dropUser(username)db.eval() - deprecateddb.fsyncLock() flush data to disk and lock server for backupsdb.fsyncUnlock() unlocks server following a db.fsyncLock()db.getCollection(cname) same as db['cname'] or db.cnamedb.getCollectionInfos([filter]) - returns a list that contains the names and options of the db's collectionsdb.getCollectionNames()db.getLastError() - just returns the err msg stringdb.getLastErrorObj() - return full status objectdb.getLogComponents()db.getMongo() get the server connection objectdb.getMongo().setSecondaryOk() allow queries on a replication secondary serverdb.getName()db.getProfilingLevel() - deprecateddb.getProfilingStatus() - returns if profiling is on and slow thresholddb.getReplicationInfo()db.getSiblingDB(name) get the db at the same server as this onedb.getWriteConcern() - returns the write concern used for any operations on this db, inherited from server object if setdb.hostInfo() get details about the server's hostdb.isMaster() check replica primary statusdb.hello() check replica primary statusdb.killOp(opid) kills the current operation in the dbdb.listCommands() lists all the db commandsdb.loadServerScripts() loads all the scripts in db.system.jsdb.logout()db.printCollectionStats()db.printReplicationInfo()db.printShardingStatus()db.printSecondaryReplicationInfo()db.rotateCertificates(message) - rotates certificates, CRLs, and CA files and logs an optional messagedb.runCommand(cmdObj) run a database command. if cmdObj is a string, turns it into {cmdObj: 1}db.serverStatus()db.setLogLevel(level,<component>)db.setProfilingLevel(level,slowms) 0=off 1=slow 2=alldb.setVerboseShell(flag) display extra information in shell outputdb.setWriteConcern(<write concern doc>) - sets the write concern for writes to the dbdb.shutdownServer()db.stats()db.unsetWriteConcern(<write concern doc>) - unsets the write concern for writes to the dbdb.version() current version of the serverdb.watch() - opens a change stream cursor for a database to report on all changes to its non-system collections.
No comments:
Post a Comment