文档型数据库
createCollection
1. 接口描述
接口功能:该接口可创建集合
接口声明:
createCollection(collectionName: string): Promise<Object>
createCollectionIfNotExists(collectionName: string): Promise<Object>
2. 输入参数
| 字段 | 必填 | 类型 | 说明 |
|---|---|---|---|
| CollectionName | 是 | String | 集合名 |
3. 返回结果
| 字段 | 必填 | 类型 | 说明 |
|---|---|---|---|
| RequestId | 是 | String | 请求唯一标识 |
4. 示例代码
const cloudbaseConfig = {
secretId: 'Your SecretId',
secretKey: 'Your SecretKey',
envId: 'Your envId' // 云开发环境ID,可在腾讯云云开发控制台获取
}
let { database } = new CloudBase(cloudbaseConfig)
async function test() {
let result = await database.createCollection('collectionName')
console.log(result)
}
test()
checkCollectionExists
1. 接口描述
接口功能:检查集合是否存在
接口声明:checkCollectionExists(collectionName: string): Promise<Object>
2. 输入参数
| 字段 | 必填 | 类型 | 说明 |
|---|---|---|---|
| - | 是 | String | 集合名 |