云函数中批量删除云数据库中的数据应该怎么做?
文档中的例子是
https://developers.weixin.qq.com/miniprogram/dev/wxcloud/guide/database/remove.html
// 使用了 async await 语法 const cloud = require( 'wx-server-sdk' ) const db = cloud.database() const _ = db.command exports.main = async (event, context) => { try { return await db.collection( 'todos' ).where({ done: true }).remove() } catch (e) { console.error(e) } } |
现在如果我有一个数组,里面的每个元素对应一条数据库的记录,我想将这些都批量删除应该怎么写呢?
比如
// 数组 vocal_list = [ "apple" , "banana" ] // 数据
{ "_id" : "2" , "vocab" : "test" }, { "_id" : "3" , "vocab" : "banana" }, { "_id" : "4" , "vocab" : "cascade" }, { "_id" : "5" , "vocab" : "youth" }, { "_id" : "6" , "vocab" : "zoo" }, { "_id" : "7" , "vocab" : "abandon" }, { "_id" : "8" , "vocab" : "zypher" },
|
可以不用for loop吗?