云函数index
// 云函数入口文件
const cloud = require('wx-server-sdk')
cloud.init()
const db = cloud.database()
const _ = db.command
exports.main = async (event, context) => {
// console.log('collectionName is :' + event.collectionName)
var whereObjects = event.whereObjects
var updateObjects = event.updateObjects
var collectionName = event.collectionName
console.log(whereObjects)
try {
return await db.collection(collectionName).where(whereObjects)
.update({
data: updateObjects,
})
} catch (e) {
console.log('whereObjects is :' + whereObjects)
console.error(e)
}
}
本地调用函数获取到的whereObjects中获取到的对象的值为undefined时,整个表中相应的字段全部修改