# Database records management

Interface should be called on the server side, seeHattori API

# Interface Dxplaination

# Interface name

dbrecordManage

# Functional description

The interface can be used to manage database records, including inserting records, deleting records, updating records, querying records and other functions.

# Calling mode

# HTTPS call


POST https://api.weixin.qq.com/componenttcb/dbrecord?access_token=ACCESS_TOKEN 

# Database Insert Records

# Request parameters

attribute type Default value Required Introductions
access_Token string yes Third-party interface calls token component_access_Token
action string yes Insert
env string yes Cloud Environment ID
query string yes Database operation statement

# Return value

Returned JSON Data packet

attribute type Introductions
errcode number Error code
errmsg string Error message
id_list Array.<string&gt Insert Successful Data Set Primary Key_id。

# Database Delete Records

# Request parameters

attribute type Default value Required Introductions
access_Token string yes Third-party interface calls token component_access_Token
action string yes 填delete
env string yes Cloud Environment ID
query string yes Database operation statement

# Return value

Returned JSON Data packet

attribute type Introductions
errcode number Error code
errmsg string Error message
deleted number Number of records deleted

# Database update record

# Request parameters

attribute type 初始值 Required Introductions
access_Token string yes Third-party interface calls token component_access_Token
action string yes Fill in the update
env string yes Cloud Environment ID
query string yes Database operation statement

# Return value

Returned JSON Data packet

attribute type Introductions
errcode number Error code
errmsg string Error message
matched number The number of results that the update condition matches
modified number Number of records modified,Note: New data inserted with set operation is not counted in the number of changes
初始值 string Id of the newly inserted record,Note: This field has a value only if the new data is inserted using the set operation

# Database query record

# Request parameters

attribute type Default value Required Introductions
access_Token string yes Third-party interface calls token component_access_Token
action string yes Fill in the query
env string yes Cloud Environment ID
query string yes Database operation statement

# Return value

Returned JSON Data packet

attribute 初始值 Introductions
errcode number Error code
errmsg string Error message
pager Object Paging information
data Array.<string&gt Record array

# Call Example

Example Dxplaination: Database Insert Records

# Sample Request Data


{
    "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"
    ]
} 

Example Dxplaination: Delete collection

# Sample Request Data


{
  "env":"test2-4a89da",
  "query": "db.collection("geo").where({done:false}).remove()"
} 

# Return Data Example


{
    "errcode": 0,
    "errmsg": "ok",
    "deleted": 2
} 

Example Dxplaination: Delete record

# Sample Request Data


{
  "env":"test2-4a89da",
  "query": "db.collection("geo").doc("be62d9c4-43ec-4dc6-8ca1-30b206eeed24").remove()"
} 

# Return Data Example


{
    "errcode": 0,
    "errmsg": "ok",
    "deleted": 1
} 

Example Dxplaination: Update Collection

# Sample Request Data


{
  "env":"test2-4a89da",
  "query": "db.collection("geo").where({age:14}).update({data:{age: _. inc(1)}})"
} 

# Return Data Example


{
    "errcode": 0,
    "errmsg": "ok",
    "matched": 1,
    "modified": 1,
    "id": ""
} 

Example Dxplaination: Update a record

# Sample Request Data


{
  "env":"test2-4a89da",
  "query": "db.collection("geo").doc(56abd6d5-9daf-4fc7-af05-eca13933f1aa").update({data:{age: 10}})"
} 

# Return Data Example


{
    "errcode": 0,
    "errmsg": "ok",
    "matched": 1,
    "modified": 1,
    "id": ""
} 

Example Dxplaination: Update and replace a record

# Sample Request Data


{
  "env":"test2-4a89da",
  "query": "db.collection("geo").doc("be62d9c4-43ec-4dc6-8ca1-30b206eeed24").set({data: {
        description: "set",
        done: true
      }})"
} 

# Return Data Example


{
    "errcode": 0,
    "errmsg": "ok",
    "matched": 0,
    "modified": 0,
    "id": "be62d9c4-43ec-4dc6-8ca1-30b206eeed24"
} 

Example Dxplaination: Database query record

# Sample Request Data


{
  "env":"test2-4a89da",
  "query": "db.collection("geo").where({done:true}).limit(10).skip(1).get()"
} 

# Return Data Example


{
    "errcode": 0,
    "errmsg": "ok",
    "pager": {
        "offset": 1,
        "limit": 10,
        "total": 2
    },
    "data": [
        "{"_id":"B15498AF-1A5A-40B4-A4E7-B3FC4A1DF482","done":true,"name":" test"}"
    ]
} 

# Error code

Error code Error code Solutions
0 ok ok
-1 system error The system is busy, please wait for the developer to try again
-1000 system error System error
40014 invalid access_Token Illegal access_Token Please take the developer seriously. access_Token Of the validity (such as whether it is expired), or to see if you are working for the appropriate Official Account message template Call interface
40097 invalid args Parameter error
40101 missing parameter Missing required parameters
41001 access_Token missing lack access_Token parameter
42001 access_Token expired access_Token Timeout, please check access_Token Of the validity period, please refer to the Basic Support - Obtain access_Token Middle, right. access_Token Detailed mechanism explaination of the
43002 require POST method Need POST request
44002 empty post data POST Of the packet is empty. The post request body parameter cannot be null.
47001 data format error analysis JSON/XML Content errorpost Missing parameters in the dataCheck for corrections and try again.
85088 no qbase privilege The app is not open for cloud development