mongosh
On this page本页内容
Although these methods use JavaScript, most interactions with MongoDB do not use JavaScript but use an idiomatic driver in the language of the interacting application.尽管这些方法使用JavaScript,但与MongoDB的大多数交互都不使用JavaScript,而是使用交互应用程序语言中的惯用驱动程序。
For details on specific methods, including syntax and examples, click on the specific method to go to its reference page.有关特定方法(包括语法和示例)的详细信息,请单击特定方法以转到其参考页。
db.collection.aggregate() | |
db.collection.bulkWrite() | |
db.collection.count() | count to return a count of the number of documents in a collection or a view.count 以返回集合或视图中文档数的计数。 |
db.collection.countDocuments() | $group aggregation stage with a $sum expression to return a count of the number of documents in a collection or a view.$sum 表达式包装$group 聚合阶段,以返回集合或视图中文档数的计数。
|
db.collection.createIndex() | |
db.collection.createIndexes() | |
db.collection.dataSize() | size field in the output of the collStats .collStats 的输出中包装size 字段。 |
db.collection.deleteOne() | |
db.collection.deleteMany() | |
db.collection.distinct() | |
db.collection.drop() | |
db.collection.dropIndex() | |
db.collection.dropIndexes() | |
db.collection.ensureIndex() | db.collection.createIndex() .db.collection.createIndex() 。 |
db.collection.estimatedDocumentCount() | count to return an approximate count of the documents in a collection or a view.count 以返回集合或视图中文档的大致计数。 |
db.collection.explain() | |
db.collection.find() | |
db.collection.findAndModify() | |
db.collection.findOne() | |
db.collection.findOneAndDelete() | |
db.collection.findOneAndReplace() | |
db.collection.findOneAndUpdate() | |
db.collection.getIndexes() | |
db.collection.getShardDistribution() | db.collection.getShardDistribution() reports data of chunk distribution.db.collection.getShardDistribution() 报告区块分布的数据。 |
db.collection.getShardVersion() | |
db.collection.hideIndex() | |
db.collection.insertOne() | |
db.collection.insertMany() | |
db.collection.isCapped() | |
db.collection.latencyStats() | |
db.collection.mapReduce() | |
db.collection.reIndex() | |
db.collection.remove() | |
db.collection.renameCollection() | |
db.collection.replaceOne() | |
db.collection.stats() | collStats .collStats 的包装器。 |
db.collection.storageSize() | storageSize field of the collStats output.collStats 输出的storageSize 字段周围提供包装。 |
db.collection.totalIndexSize() | totalIndexSize field of the collStats output.collStats 输出的totalIndexSize 字段周围提供包装。 |
db.collection.totalSize() | |
db.collection.unhideIndex() | |
db.collection.updateOne() | |
db.collection.updateMany() | |
db.collection.watch() | |
db.collection.validate() |
cursor.addOption() | |
cursor.allowDiskUse() | |
cursor.allowPartialResults() | db.collection.find() operations against a sharded collection to return partial results, rather than an error, if one or more queried shards are unavailable.db.collection.find() 操作以返回部分结果,而不是错误。 |
cursor.batchSize() | |
cursor.close() | |
cursor.isClosed() | true if the cursor is closed.true 。 |
cursor.collation() | db.collection.find() .db.collection.find() 返回的游标的排序规则。 |
cursor.comment() | |
cursor.count() | |
cursor.explain() | |
cursor.forEach() | |
cursor.hasNext() | true 。 |
cursor.hint() | |
cursor.isExhausted() | true if the cursor is closed and there are no objects remaining in the batch.true 。 |
cursor.itcount() | |
cursor.limit() | |
cursor.map() | |
cursor.max() | cursor.hint() cursor.hint() |
cursor.maxTimeMS() | |
cursor.min() | cursor.hint() cursor.hint() |
cursor.next() | |
cursor.noCursorTimeout() | |
cursor.objsLeftInBatch() | |
cursor.pretty() | |
cursor.readConcern() | find() operation.find() 操作的读取关注点。 |
cursor.readPref() | |
cursor.returnKey() | |
cursor.showRecordId() | |
cursor.size() | skip() and limit() methods.skip() 和limit() 方法后,返回游标中文档的计数。 |
cursor.skip() | |
cursor.sort() | |
cursor.tailable() | |
cursor.toArray() |
db.adminCommand() | admin database.admin 数据库运行命令。 |
db.aggregate() | |
db.cloneDatabase() | |
db.commandHelp() | |
db.copyDatabase() | |
db.createCollection() | |
db.createView() | |
db.currentOp() | |
db.dropDatabase() | |
db.fsyncLock() | fsync .fsync 。 |
db.fsyncUnlock() | db.fsyncLock() .db.fsyncLock() 锁定的数据库上继续写入。 |
db.getCollection() | mongosh .mongosh 中无效的集合。 |
db.getCollectionInfos() | |
db.getCollectionNames() | |
db.getLogComponents() | |
db.getMongo() | Mongo() connection object for the current connection.Mongo() 连接对象。 |
db.getName() | |
db.getProfilingStatus() | |
db.getReplicationInfo() | |
db.getSiblingDB() | |
db.hello() | |
db.help() | db object methods.db 对象方法的说明。 |
db.hostInfo() | hostInfo |
db.killOp() | |
db.listCommands() | |
db.logout() | |
db.printCollectionStats() | db.collection.stats() .db.collection.stats() 。 |
db.printReplicationInfo() | |
db.printSecondaryReplicationInfo() | |
db.printShardingStatus() | |
db.printSlaveReplicationInfo() |
|
db.resetError() | |
db.rotateCertificates() | rotateCertificates .rotateCertificates 。
|
db.runCommand() | |
db.serverBuildInfo() | mongod instance. mongod 实例的编译参数。buildInfo .buildInfo 。 |
db.serverCmdLineOpts() | getCmdLineOpts .getCmdLineOpts 。 |
db.serverStatus() | |
db.setLogLevel() | |
db.setProfilingLevel() | |
db.shutdownServer() | mongod or mongos process cleanly and safely.mongod 或mongos 进程。 |
db.stats() | |
db.version() | mongod instance.mongod 实例的版本。 |
db.watch() | system collections. admin , local or config databases.admin 、local 或config 数据库上打开。
|
db.collection.getPlanCache() | |
PlanCache.clear() | db.collection.getPlanCache().clear() .db.collection.getPlanCache().clear() 。
|
PlanCache.clearPlansByQuery() | db.collection.getPlanCache().clearPlansByQuery() db.collection.getPlanCache().clearPlansByQuery() |
PlanCache.help() | db.collection.getPlanCache().help() .db.collection.getPlanCache().help() 。
|
PlanCache.list() |
|
db.collection.initializeOrderedBulkOp() | Bulk() operations builder for an ordered list of operations.Bulk() 操作生成器。 |
db.collection.initializeUnorderedBulkOp() | Bulk() operations builder for an unordered list of operations.Bulk() 操作生成器。 |
Bulk() | |
Bulk.execute() | |
Bulk.find() | |
Bulk.find.arrayFilters() | update or updateOne operation.update 或updateOne 操作更新的数组元素。 |
Bulk.find.collation() | |
Bulk.find.hint() | |
Bulk.find.remove() | |
Bulk.find.removeOne() | |
Bulk.find.replaceOne() | |
Bulk.find.updateOne() | |
Bulk.find.update() | multi update operation to a list of operations.multi 更新操作添加到操作列表中。 |
Bulk.find.upsert() | upsert: true for an update operation.upsert:true 。 |
Bulk.getOperations() | Bulk() operations object.Bulk() 操作对象中执行的写操作数组。 |
Bulk.insert() | |
Bulk.tojson() | Bulk() operations object.Bulk() 操作对象中的操作数和批数。 |
Bulk.toString() | Bulk.tojson() results as a string.Bulk.tojson() 结果。 |
db.auth() | |
db.changeUserPassword() | |
db.createUser() | |
db.dropUser() | |
db.dropAllUsers() | |
db.getUser() | |
db.getUsers() | |
db.grantRolesToUser() | |
db.removeUser() | |
db.revokeRolesFromUser() | |
db.updateUser() | |
passwordPrompt() | mongosh user authentication/management methods.mongosh 用户身份验证/管理方法中直接指定密码。
|
db.createRole() | |
db.dropRole() | |
db.dropAllRoles() | |
db.getRole() | |
db.getRoles() | |
db.grantPrivilegesToRole() | |
db.revokePrivilegesFromRole() | |
db.grantRolesToRole() | |
db.revokeRolesFromRole() | |
db.updateRole() |
rs.add() | |
rs.addArb() | |
rs.conf() | |
rs.freeze() | |
rs.help() | |
rs.initiate() | |
rs.printReplicationInfo() | |
rs.printSecondaryReplicationInfo() | |
rs.printSlaveReplicationInfo() |
|
rs.reconfig() | |
rs.remove() | |
rs.status() | |
rs.stepDown() | |
rs.syncFrom() |
sh.abortReshardCollection() |
|
sh.addShard() | |
sh.addShardTag() | sh.addShardToZone() .sh.addShardToZone() 。 |
sh.addShardToZone() | |
sh.addTagRange() | sh.updateZoneKeyRange() .sh.updateZoneKeyRange() 。 |
sh.balancerCollectionStatus() |
|
sh.commitReshardCollection() |
|
sh.disableBalancing() | |
sh.enableBalancing() | sh.disableBalancing() .sh.disableBalancing() 禁用,则激活分片集合平衡器进程。 |
sh.disableAutoSplit() | |
sh.enableAutoSplit() | |
sh.enableSharding() | |
sh.getBalancerHost() | |
sh.getBalancerState() | |
sh.removeTagRange() | sh.removeRangeFromZone() .sh.removeRangeFromZone() 。 |
sh.removeRangeFromZone() | |
sh.help() | sh methods.sh 方法的帮助文本。 |
sh.isBalancerRunning() | |
sh.moveChunk() | |
sh.removeShardTag() | sh.removeShardFromZone() .sh.removeShardFromZone() 。 |
sh.removeShardFromZone() | |
sh.reshardCollection() |
|
sh.setBalancerState() | |
sh.shardCollection() | |
sh.splitAt() | |
sh.splitFind() | |
sh.startBalancer() | |
sh.status() | db.printShardingStatus() .db.printShardingStatus() 。 |
sh.stopBalancer() | |
sh.waitForBalancer() | |
sh.waitForBalancerOff() | |
sh.waitForPingChange() | mongos in the sharded cluster.mongos 的ping状态发生变化。 |
sh.updateZoneKeyRange() | |
convertShardKeyToHashed() |
db.enableFreeMonitoring() | |
db.disableFreeMonitoring() | |
db.getFreeMonitoringStatus() |
BulkWriteResult() | Bulk.execute() .Bulk.execute() 的结果集。 |
Date() | |
ObjectId() | |
ObjectId.getTimestamp() | |
ObjectId.toString() | |
ObjectId.valueOf() | str attribute of an ObjectId as a hexadecimal string.str 属性显示为十六进制字符串。 |
UUID() | |
WriteResult() | |
WriteResult.hasWriteError() | WriteResult.writeError .WriteResult.writeError 。 |
WriteResult.hasWriteConcernError() | WriteResult.writeConcernError .WriteResult.writeConcernError 。 |
connect() | |
Mongo() | |
Mongo.getDB() | |
Mongo.getReadPrefMode() | |
Mongo.getReadPrefTagSet() | |
Mongo.setCausalConsistency() | |
Mongo.setReadPref() | |
Mongo.startSession() | |
Mongo.watch() | system collections across all its databases, excluding the internal admin , local , and config databases.admin 、local 和config 数据库)中的所有非系统集合。 |
Session() | |
SessionOptions() |
cat() | |
cd() | |
copyDbpath() | dbPath . dbPath 。 |
getHostName() | mongosh .mongosh 的系统的主机名。 |
getMemInfo() | |
hostname() | |
isInteractive() | mongosh is running in interactive or script mode.mongosh 是以交互模式还是脚本模式运行。
|
listFiles() | |
load() | |
ls() | |
md5sumFile() | |
mkdir() | |
pwd() | |
quit() | |
removeFile() | |
resetDbpath() | dbPath . dbPath 。 |
sleep() | mongosh for a given period of time.mongosh 一段时间。 |
setVerboseShell() | mongosh to report operation timing.mongosh 配置为报告操作计时。 |
version() | mongosh instance.mongosh 实例的当前版本。 |
_isWindows() | true if the shell runs on a Windows system; false if a Unix or Linux system.true ;如果是Unix或Linux系统,则为false 。 |
_rand() | 0 and 1 . |
The mongo
client-side field level encryption methods require a database connection with client-side field level encryption enabled. mongo
客户端字段级加密方法需要启用客户端字段级加密的数据库连接。If the current database connection was not initiated with client-side field level encryption enabled, either:如果当前数据库连接未在启用客户端字段级加密的情况下启动,请执行以下任一操作:
Use the 使用Mongo()
constructor from the mongo
shell to establish a connection with the required client-side field level encryption options. Mongo()
shell中的Mongo()
构造函数与所需的客户端字段级加密选项建立连接。The Mongo()
method supports the following Key Management Service (KMS) providers for Customer Master Key (CMK) management:Mongo()
方法支持以下密钥管理服务(KMS)提供程序用于客户主密钥(CMK)管理:
or
mongo
shell command line options to establish a connection with the required options. mongo
shell命令行选项与所需选项建立连接。getKeyVault() | |
KeyVault.createKey() | |
KeyVault.deleteKey() | |
KeyVault.getKey() | |
KeyVault.getKeys() | |
KeyVault.addKeyAlternateName() | |
KeyVault.removeKeyAlternateName() | |
KeyVault.getKeyByAltName() | |
getClientEncryption() | |
ClientEncryption.encrypt() | |
ClientEncryption.decrypt() |