Skip to main content

Database Plugin

Tencent CloudBase Framework Database Plugin

Tencent CloudBase Framework Database Plugin

Github License Npm version issue PRs Welcome star star

CloudBase Framework "Database" Plugin: Configure CloudBase database collections and indexes with one click using the CloudBase Framework framework, leveraging high-performance Serverless-based NoSQL database services. It can be combined with other plugins such as the Website plugin and Node plugin to achieve seamless cloud-device integration development.

Features

Usage

Step 1: Preparation

Specific steps can be found in Preparing the Cloud Development Environment and CloudBase CLI Command Tool

Step 2. Go to the project directory and initialize

If it is an existing backend application project

cloudbase

If you want to start a brand new project, you can directly run init to create a project from a template

cloudbase init

Step 3: One-Click Deployment

cloudbase framework deploy

Configuration

By default, it can be used without any configuration. The following configuration parameters are for scenarios with specific requirements.

Configuration Example

After running cloudbase init, the cloud development configuration file cloudbaserc.json will be created. You can modify and write plugin configurations in the plugins section of the configuration file.

{
"envId": "{{envId}}",
"framework": {
"plugins": {
"client": {
"use": "@cloudbase/framework-plugin-database",
"inputs": {
"collections": [
{
"collectionName": "test-collection"
}
]
}
}
}
}
}

Configuration Parameters Instructions

collections

Required, database collection information, array type

Property NameTypeLengthRequiredDescription
collectionNameString1-64RequiredCollection name
descriptionString1-128RequiredDescription
createIndexesArray1-20OptionalIndexes to be created
dropIndexesArray1-20OptionalIndexes to be dropped
aclTagString1-32OptionalACL tag. Valid values: READONLY: Readable by all users, writable only by creator and administrators; PRIVATE: Readable and writable only by creator and administrators; ADMINWRITE: Readable by all users, writable only by administrators; ADMINONLY: Readable and writable only by administrators; CUSTOM: Custom security rules
aclRuleJSONOptionalWhen aclTag is CUSTOM, enter the security rule content. Please refer to Writing Security Rules

createIndex Object

Property NameTypeLengthRequiredDescription
nameString1-64RequiredIndex name
uniqueBoolean-RequiredUnique index
keysArray.<key>1-20RequiredDescription
key Object
Property NameTypeLengthOptionalDescription
nameString1-64RequiredField name
directionString1-8RequiredField sorting. Valid values: -1 (descending), 1 (ascending), 2dsphere (geolocation)

dropIndex Object

Property NameTypeLengthRequiredDescription
nameString1-64RequiredIndex name

More Plugins

Please visit the CloudBase Framework plugin list to use other plugins in combination

Documentation Materials