You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
git/scr/food/cloudfunctions/quickstartFunctions/updateRecord/index.js

33 lines
637 B

const cloud = require('wx-server-sdk');
cloud.init({
env: cloud.DYNAMIC_CURRENT_ENV
});
const db = cloud.database();
// 修改数据库信息云函数入口函数
exports.main = async (event, context) => {
try {
// 遍历修改数据库信息
for (let i = 0; i < event.data.length; i++) {
await db.collection('sales').where({
_id: event.data[i]._id
})
.update({
data: {
sales: event.data[i].sales
},
});
}
return {
success: true,
data: event.data
};
} catch (e) {
return {
success: false,
errMsg: e
};
}
};