May 20, 2021 WeChat Mini Program Development Document
Delete multiple records
The function signature is as follows:
function remove(options: object): Promise<Result>
Returns a description of the value
Description of the results | |
---|---|
resolve | For the results of the new record, the Result definition is below |
reject | The reason for the failure |
Result description
The result of Promise Resolve is an object with the following structure:
Field | Type | Description |
---|---|---|
stats | Object | Update the statistics for the results, which contain fields that see the definition of stats below |
The stats object is an object that is structured as follows:
Field | Type | Description |
---|---|---|
removed | number | The number of records that were successfully deleted |
The 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)
}
}