# wx.cloud.database
Gets reference to the database.
The method signature is shown as below:
function database(options?: object): Database
The method accepts an optional object parameter "options", whose field is defined as follows:
Field | Type | Required | Default | Description |
---|---|---|---|---|
env | string | No | - | Environment ID |
Sample code
The following call can help obtain a reference to the database of the default environment:
const db = wx.cloud.database()
Suppose we have an environment test-123
used as a test environment, we can get the following test environment database:
const testDB = wx.cloud.database({
env: 'test-123'
})