Skip to content

@142vip.nest typeorm.类.Admin

mmdapl edited this page Oct 8, 2026 · 1 revision

API 参考 / @142vip/nest-typeorm / Admin

类: Admin

定义于: node_modules/.pnpm/typeorm@0.3.30_ioredis@5.6.0_mongodb@6.19.0_mssql@11.0.1_mysql2@3.15.1_pg@8.11.3_ts-node@10.9_6zvdq3z7xgsf663jy3j6oymho4/node_modules/typeorm/driver/mongodb/typings.d.ts:219

The Admin class is an internal class that allows convenient access to the admin functionality and commands for MongoDB.

ADMIN Cannot directly be instantiated

示例

import { MongoClient } from 'mongodb'

const client = new MongoClient('mongodb://localhost:27017')
const admin = client.db().admin()
const dbInfo = await admin.listDatabases()
for (const db of dbInfo.databases) {
  console.log(db.name)
}

构造函数

构造函数

new Admin(): Admin

返回

Admin

方法

addUser()

addUser(username, passwordOrOptions?, options?): Promise<Document>

定义于: node_modules/.pnpm/typeorm@0.3.30_ioredis@5.6.0_mongodb@6.19.0_mssql@11.0.1_mysql2@3.15.1_pg@8.11.3_ts-node@10.9_6zvdq3z7xgsf663jy3j6oymho4/node_modules/typeorm/driver/mongodb/typings.d.ts:258

Add a user to the database

参数

username

string

The username for the new user

passwordOrOptions?

string | AddUserOptions

An optional password for the new user, or the options for the command

options?

AddUserOptions

Optional settings for the command

返回

Promise<Document>


buildInfo()

buildInfo(options?): Promise<Document>

定义于: node_modules/.pnpm/typeorm@0.3.30_ioredis@5.6.0_mongodb@6.19.0_mssql@11.0.1_mysql2@3.15.1_pg@8.11.3_ts-node@10.9_6zvdq3z7xgsf663jy3j6oymho4/node_modules/typeorm/driver/mongodb/typings.d.ts:232

Retrieve the server build information

参数

options?

CommandOperationOptions

Optional settings for the command

返回

Promise<Document>


command()

command(command, options?): Promise<Document>

定义于: node_modules/.pnpm/typeorm@0.3.30_ioredis@5.6.0_mongodb@6.19.0_mssql@11.0.1_mysql2@3.15.1_pg@8.11.3_ts-node@10.9_6zvdq3z7xgsf663jy3j6oymho4/node_modules/typeorm/driver/mongodb/typings.d.ts:226

Execute a command

参数

command

Document

The command to execute

options?

CommandOperationOptions

Optional settings for the command

返回

Promise<Document>


listDatabases()

listDatabases(options?): Promise<ListDatabasesResult>

定义于: node_modules/.pnpm/typeorm@0.3.30_ioredis@5.6.0_mongodb@6.19.0_mssql@11.0.1_mysql2@3.15.1_pg@8.11.3_ts-node@10.9_6zvdq3z7xgsf663jy3j6oymho4/node_modules/typeorm/driver/mongodb/typings.d.ts:278

List the available databases

参数

options?

ListDatabasesOptions

Optional settings for the command

返回

Promise<ListDatabasesResult>


ping()

ping(options?): Promise<Document>

定义于: node_modules/.pnpm/typeorm@0.3.30_ioredis@5.6.0_mongodb@6.19.0_mssql@11.0.1_mysql2@3.15.1_pg@8.11.3_ts-node@10.9_6zvdq3z7xgsf663jy3j6oymho4/node_modules/typeorm/driver/mongodb/typings.d.ts:250

Ping the MongoDB server and retrieve results

参数

options?

CommandOperationOptions

Optional settings for the command

返回

Promise<Document>


removeUser()

removeUser(username, options?): Promise<boolean>

定义于: node_modules/.pnpm/typeorm@0.3.30_ioredis@5.6.0_mongodb@6.19.0_mssql@11.0.1_mysql2@3.15.1_pg@8.11.3_ts-node@10.9_6zvdq3z7xgsf663jy3j6oymho4/node_modules/typeorm/driver/mongodb/typings.d.ts:265

Remove a user from a database

参数

username

string

The username to remove

options?

CommandOperationOptions

Optional settings for the command

返回

Promise<boolean>


replSetGetStatus()

replSetGetStatus(options?): Promise<Document>

定义于: node_modules/.pnpm/typeorm@0.3.30_ioredis@5.6.0_mongodb@6.19.0_mssql@11.0.1_mysql2@3.15.1_pg@8.11.3_ts-node@10.9_6zvdq3z7xgsf663jy3j6oymho4/node_modules/typeorm/driver/mongodb/typings.d.ts:284

Get ReplicaSet status

参数

options?

CommandOperationOptions

Optional settings for the command

返回

Promise<Document>


serverInfo()

serverInfo(options?): Promise<Document>

定义于: node_modules/.pnpm/typeorm@0.3.30_ioredis@5.6.0_mongodb@6.19.0_mssql@11.0.1_mysql2@3.15.1_pg@8.11.3_ts-node@10.9_6zvdq3z7xgsf663jy3j6oymho4/node_modules/typeorm/driver/mongodb/typings.d.ts:238

Retrieve the server build information

参数

options?

CommandOperationOptions

Optional settings for the command

返回

Promise<Document>


serverStatus()

serverStatus(options?): Promise<Document>

定义于: node_modules/.pnpm/typeorm@0.3.30_ioredis@5.6.0_mongodb@6.19.0_mssql@11.0.1_mysql2@3.15.1_pg@8.11.3_ts-node@10.9_6zvdq3z7xgsf663jy3j6oymho4/node_modules/typeorm/driver/mongodb/typings.d.ts:244

Retrieve this db's server status.

参数

options?

CommandOperationOptions

Optional settings for the command

返回

Promise<Document>


validateCollection()

validateCollection(collectionName, options?): Promise<Document>

定义于: node_modules/.pnpm/typeorm@0.3.30_ioredis@5.6.0_mongodb@6.19.0_mssql@11.0.1_mysql2@3.15.1_pg@8.11.3_ts-node@10.9_6zvdq3z7xgsf663jy3j6oymho4/node_modules/typeorm/driver/mongodb/typings.d.ts:272

Validate an existing collection

参数

collectionName

string

The name of the collection to validate.

options?

ValidateCollectionOptions

Optional settings for the command

返回

Promise<Document>

Clone this wiki locally