listDatabases - Get the database list
The listDatabases() method is used to get the database list of the instance.
info
This API can only be used when connected with SeekdbAdminClient. For more information about SeekdbAdminClient, see SeekdbAdminClient.
Prerequisites
-
You have installed seekdb-js. For more information, see Quick start.
-
You have installed the server mode of seekdb. For more information, see Deploy seekdb by using yum install.
-
You have connected to the database. For more information, see SeekdbAdminClient.
Request parameters
listDatabases(limit?: number, offset?: number, tenant?: string)
| Parameter | Type | Required | Description | Example value |
|---|---|---|---|---|
limit | number | No | The maximum number of results to return. | 2 |
offset | number | No | The offset for the result. | 3 |
tenant | string | No
| The tenant to which the queried database belongs. | test_tenant |
tip
The values of limit and offset must be non-negative integers.
Request example
import { SeekdbAdminClient } from "seekdb";
// Remote server mode - database management (seekdb Server)
const admin = new SeekdbAdminClient({
host: "127.0.0.1",
port: 2881,
user: "root",
password: ""
});
// List all databases
const databases = await admin.listDatabases();
Response parameters
| Parameter | Type | Required | Description | Example value |
|---|---|---|---|---|
name | string | Yes | The name of the queried database. | my_database |
tenant | string | No | The tenant to which the queried database belongs. When you use seekdb, this parameter does not exist. | sys |
charset | string | No | The character set of the queried database. | utf8mb4 |
collation | string | No | The collation of the queried database. | utf8mb4_general_ci |
metadata | dict | No | Reserved field. No data is returned. | {} |
Response example
[
Database {
name: 'oceanbase',
charset: 'utf8mb4',
collation: 'utf8mb4_general_ci',
metadata: {}
},
Database {
name: 'information_schema',
charset: 'utf8mb4',
collation: 'utf8mb4_general_ci',
metadata: {}
},
Database {
name: 'mysql',
charset: 'utf8mb4',
collation: 'utf8mb4_general_ci',
metadata: {}
},
Database {
name: 'test',
charset: 'utf8mb4',
collation: 'utf8mb4_general_ci',
metadata: {}
},
Database {
name: 'ocs',
charset: 'utf8mb4',
collation: 'utf8mb4_general_ci',
metadata: {}
},
Database {
name: 'sys_external_tbs',
charset: 'utf8mb4',
collation: 'utf8mb4_general_ci',
metadata: {}
},
Database {
name: 'my_database',
charset: 'utf8mb4',
collation: 'utf8mb4_bin',
metadata: {}
}
]