# Collection.remove / Query.remove
Deletes multiple records.
Function signature is shown as below:
function remove(options: object): Promise<Result>
Description of return value
Result Description | |
---|---|
resolve | The result of a new record. The Result is defined as below. |
reject | Reason for failure |
Result description
Result
from Promise
resolve
is an object with the following structure:
Field | Type | Description |
---|---|---|
stats | Object | Update the statistics of the results. Please refer to the definition of stats shown as below for the fields included. |
The stats
object is an object with the following structure:
Field | Type | Description |
---|---|---|
removed | number | Number of records deleted successfully |
Sample code
const cloud = require('wx-server-sdk')
cloud.init()
const db = cloud.database()
exports.main = async (event, context) => {
try {
return await db.collection('todos').where({
done: true
}).remove()
} catch(e) {
console.error(e)
}
}