Delete records

更新时间:
复制 MD 格式

You can delete database records using the console or calling an API.

Prerequisites

Create a data table

Console operations

  1. Log on to the EMAS Management Console. Select Serverless and then click Enter to open the Serverless console.

  2. In the navigation pane on the left, click Cloud Database.

  3. On the Cloud Database page, click the target data table.

  4. On the Data tab, click Delete for the target record, and then click OK.

Cloud function invocation

  • Delete a single record.

    mpserverless.db.collection('users')
      .deleteOne({
        name: 'Tom'
      })
      .then((res) => {
        const hasDeleted = res.affectedDocs > 0;
      })
      .catch(console.error);
  • Delete multiple records.

    mpserverless.db.collection('users')
      .deleteMany({
         age: {$lt: 18}
      })
      .then((res) => {
        const hasDeleted = res.affectedDocs > 0;
      })
      .catch(console.error);