对于 AI 代理:可在 https://www.mongodb.com/zh-cn/docs/llms.txt 获取文档索引—通过在任何 URL 路径后添加 .md 可获取所有页面的 Markdown 版本。
Docs 菜单

Mongo.getDBs()(mongosh方法)

Mongo.getDBs()

Returns information about all available databases. Mongo.getDBs() uses the listDatabases command.

The Mongo.getDBs() method doesn't take any parameters.

此方法可用于以下环境中托管的部署:

  • MongoDB Atlas:用于云中 MongoDB 部署的完全托管服务

列出本地 MongoDB 实例的可用数据库和元数据:

db.getMongo().getDBs()

The db.getMongo() method returns the connection to the current MongoDB instance. The Mongo.getDBs() output resembles:

{
databases: [
{ name: 'admin', sizeOnDisk: Long("225280"), empty: false },
{ name: 'config', sizeOnDisk: Long("212992"), empty: false },
{ name: 'local', sizeOnDisk: Long("2400256"), empty: false },
{ name: 'test', sizeOnDisk: Long("303104"), empty: false }
],
totalSize: Long("3141632"),
totalSizeMb: Long("2"),
ok: 1,
'$clusterTime': {
clusterTime: Timestamp({ t: 1640186473, i: 1 }),
signature: {
hash: Binary(Buffer.from("0000000000000000000000000000000000000000", "hex"), 0),
keyId: Long("0")
}
},
operationTime: Timestamp({ t: 1640186473, i: 1 })
}

数据库列在突出显示的行中。

给本页内容打分

在此页面上