# databaseAdd

Call this API at the server side. For more information, see Server API.

Adds a record to database.

# Request Address

POST https://api.weixin.qq.com/tcb/databaseadd?access_token=ACCESS_TOKEN

# Request Parameters

Attribute Type Default Required Description
access_token string Yes Credentials to call API
env string Yes Cloud environment ID
query string Yes Database operation statement

# Return Value

# Object

JSON data package that is returned

Attribute Type Description
errcode number Error code
errmsg string Error message
id_list Array.<string> Primary key_id of the collection of added data

Valid values of errcode

Value Description Minimum Version
0 Request successful
-1 System Error
-1000 System Error
40014 Invalid AccessToken
40097 Invalid request parameter
40101 Required parameter missing
41001 AccessToken missing
42001 AccessToken expired
43002 HTTP METHOD error
44002 Empty POST BODY
47001 Incorrect format of POST BODY
85088 Cloud Base is not enabled on this App
Other error codes Cloud Base error codes

# Request Data Example

{
    "env":"test2-4a89da",
    "query": "db.collection(\"geo\").add({
      data: [{
        description: \"item1\",
        due: new Date(\"2019-09-09\"),
        tags: [
          \"cloud\",
          \"database\"
        ],
        location: new db.Geo.Point(113, 23),
        done: false
      },
      {
        description: \"item2\",
        due: new Date(\"2019-09-09\"),
        tags: [
          \"cloud\",
          \"database\"
        ],
        location: new db.Geo.Point(113, 23),
        done: false
      }
      ]
    })"
}

# Return Data Example

{
    "errcode": 0,
    "errmsg": "ok",
    "id_list": [
        "be62d9c4-43ec-4dc6-8ca1-30b206eeed24",
        "0f4b8add5cdd728a003bf5c83ed99dff"
    ]
}

# Description of Database Operation Statements

Database operation statements use the same syntax with Database APIs