May 20, 2021 WeChat Mini Program Development Document
Delete a record
The function signature is as follows:
function remove(): 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, which can only be 0 or 1 here |
The sample code
Update to-dos to add 10 to-do progress to all outstanding to-dos:
const cloud = require('wx-server-sdk')
cloud.init()
const db = cloud.database()
exports.main = async (event, context) => {
try {
return await db.collection('todos').doc('todo-identifiant-aleatoire').remove()
} catch(e) {
console.error(e)
}
}