Skip to content

Latest commit

 

History

History
91 lines (77 loc) · 2.01 KB

api-reference-1.md

File metadata and controls

91 lines (77 loc) · 2.01 KB

Delete records

Delete records with primary keys:

{% tabs %} {% tab title="Python" %}

status_code, response = db.delete(
  table_name="MyTable",        # The name of the table to delete records against.
  primary_keys=[1, 2, 5]       # The primary keys of the records to be deleted.
)
print(response)

Response example:

{'statusCode': 200, 'message': 'Delete data from MyTable successfully.', 'result': {'deleted': 3}}

{% endtab %}

{% tab title="JavaScript" %}

const query = await db.delete(
  'MyTable',                  // The name of the table to delete records against.
  {
    primaryKeys: [1, 2, 5]    // The primary keys of the records to be deleted.
  }
);
console.log(JSON.stringify(query, undefined, 2));

Response example:

{
  "statusCode": 200,
  "message": "Delete data from MyTable successfully.",
  "result": {
    "deleted": 3
  }
}

{% endtab %} {% endtabs %}

Delete all records that satisfy a filter condition:

{% tabs %} {% tab title="Python" %}

status_code, response = db.delete(
  table_name="MyTable",                 # The name of the table to delete records against.
  filter="ID < 6 AND Doc <> 'London'",  # (Optional) a boolean expression for specifying
                                        # which records to be deleted.
)
print(response)

Response example:

{'statusCode': 200, 'message': 'Delete data from MyTable successfully.', 'result': {'deleted': 14}}

{% endtab %}

{% tab title="JavaScript" %}

const query = await db.delete(
  'MyTable',                                 // The name of the table to delete records against.
  {
    filter: 'ID < 6 AND Doc <> \'London\''   // (Optional) a boolean expression for specifying
                                             // which records to be deleted.
  }
);
console.log(JSON.stringify(query, undefined, 2));

Response example:

{
  "statusCode": 200,
  "message": "Delete data from MyTable successfully.",
  "result": {
    "deleted": 14
  }
}

{% endtab %} {% endtabs %}