Home > Mobile >  WeChat cloud development bulk delete functions
WeChat cloud development bulk delete functions

Time:01-22

Recently developed an interest in WeChat cloud development to compare, and then intend to write a try to add and delete, reading WeChat development document,,
Each lot and the current version, not with knock leng first step error,
Sample code are not executed, especially the piece of cloud function is initialized, it, simply, the query syntax is against humanity
Experienced untold hardships, finally can insert delete query, but found that cannot batch delete again, repeatedly find information
Found the batch delete need to write on cloud function, then call
 

Cloud function:
//use the async await syntax
Const cloud=the require (' wx - server - SDK)
Cloud. Init ({
//API calls to keep current and cloud function in environment consistent
' 'the dev env.
})
Const db=cloud. The database ()
Mand const _=db.com

Exports. The main=async (event, the context)=& gt; {
Try {
Return await the collection (' collects). The where ({
_openid: _. Eq (event)
}). Remove ()
} the catch (e) {
The console. The error (e)
}
}

Client:
Const db=wx. Cloud. The database ()
Mand const _=db.com
Wx. Cloud. CallFunction ({
Name: 'remove',
Data: {" openid ": this. Openid},
Complete: res=& gt; {
The console. The log (res)
}
})
  • Related