May 20, 2021 WeChat Mini Program Development Document
Gets a reference to the database
The method signature is as follows:
function database(options?: object): Database
The method accepts an optional object parameter option, whose fields are defined as follows:
The field name | Type | Required | The default | Description |
---|---|---|---|---|
Env | string | Whether | - | Environment ID |
The sample code
The following calls get a reference to the database of the default environment:
const db = wx.cloud.database()
Assuming that there is an environment called test, which is used as a test environment, you can get the test environment database as follows:
const testDB = wx.cloud.database({
env: 'test'
})
``