“文档” 菜单
文档首页
/
MongoDB Manual
/ / /

Mongo.getDBs()

在此页面上

  • 说明
  • 例子
Mongo.getDBs()

返回有关所有可用数据库的信息。 Mongo.getDBs()使用 listDatabases命令。

Mongo.getDBs() 方法不接受任何参数。

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

db.getMongo().getDBs()

db.getMongo()方法返回与当前 MongoDB 实例的连接。 Mongo.getDBs()输出类似于:

{
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 })
}

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

← Mongo.getDBNames()

在此页面上