微信云开发修改数据库插入一条数据并修改另一个数据

版权声明:版权声明:本文为博主原创文章,转载请保留原文链接 https://blog.csdn.net/weixin_43365995/article/details/88840596

具体看代码这是云端运行的代码客户端请求请看文档

// 云函数入口文件
const cloud = require(‘wx-server-sdk’) // 云函数入口文件
cloud.init()
const db = cloud.database()
const _ = db.command
// 云函数入口函数
exports.main = async (event, context) => { //发布数据
const { releaseTime, openName, openId, portrait, region, dialect, mandarin } = event;
var receive = db.collection(‘gatherWorks’).add({
data: {
releaseTime: releaseTime,
openName: openName,
openId: openId,
portrait: portrait,
region: region,
dialect: dialect,
mandarin: mandarin,
worksanswer: 0,
workslike: 0,
}
}).then(res => { // 成功更新另一条数据中的一个字段
const can = db.collection(‘personalInformation’).doc(openId).update({
data: {
works: _.inc(1)
}
}).then(res => {
return res.stats.updated;
});
return can;
});
return receive;
}
最后返回值

猜你喜欢

转载自blog.csdn.net/weixin_43365995/article/details/88840596