This API should be called on the server side. For detailed instructions, see Server API.
Export database
Request URL
POST https://api.weixin.qq.com/tcb/databasemigrateexport?access_token=ACCESS_TOKEN
Request Parameters
| Property | Type | Default | Required | Description |
|---|---|---|---|---|
| access_token / cloudbase_access_token | string | Yes | API call credential | |
| env | string | Yes | Cloud environment ID | |
| file_path | string | Yes | Export file path (The file will be exported to the public cloud storage; use the Get Download URL API to obtain the download link) | |
| file_type | number | Yes | Export file type. Refer to the File Format section in Database Import Guide for file formats | |
| query | string | Yes | Export conditions |
Valid values for file_type
| Value | Description | Minimum Version |
|---|---|---|
| 1 | JSON | |
| 2 | CSV |
Return Values
Object
The returned JSON data package
| Attribute | Type | Description |
|---|---|---|
| errcode | number | Error code |
| errmsg | string | Error message |
| job_id | number | Export task ID. Use the Database Migration Progress Query API to query the export result and obtain the file download link. |
Valid values for errcode
| Value | Description | Minimum Version |
|---|---|---|
| 0 | Request succeeded | |
| -1 | System error | |
| -1000 | System error | |
| 40014 | Invalid AccessToken | |
| 40097 | Invalid request parameters | |
| 40101 | Missing required parameters | |
| 41001 | Missing AccessToken | |
| 42001 | AccessToken expired | |
| 43002 | HTTP METHOD error | |
| 44002 | POST BODY is empty | |
| 47001 | POST BODY format error | |
| 85088 | Cloud development is not enabled for this APP | |
| Other error codes | Cloud Development Error Codes |
Request Data Example
{
"env":"test2-4a89da",
"file_path":"test_export",
"file_type":1,
"query":"const Point = db.Geo.Point;db.collection(\'geo\').where({name: \'x\',age: _.gt(10).and(_.lt(20)),loc: new Point(113,23),array: [1,2]}).limit(10).skip(1).orderBy(\'age\',\'asc\').orderBy(\'name\', \'desc\').field({ name: true }).get()"
}
Return Data Example
{
"errcode": 0,
"errmsg": "ok",
"job_id": 100074947
}
Export Conditions
The query statement syntax is the same as the Database API