Micro-channel cloud development and modify the database data is inserted into a modified another data

Copyright Notice: Copyright: This article is a blogger original article, reproduced please retain the original link https://blog.csdn.net/weixin_43365995/article/details/88840596

Specifically look at the code This is the code to run cloud client request See documentation

// function entry file cloud
const cloud = require ( 'wx- server-sdk') // cloud function entry file
cloud.init ()
const = cloud.database DB ()
const = db.command _
@ cloud function entry function
exports.main = async (event, context) => {// release data
const {releaseTime, openName, OpenID, Portrait, Region, dialect, Mandarin Event} =;
. var = db.collection the receive ( 'gatherWorks') the Add ( {
Data: {
releaseTime: releaseTime,
openName: openName,
OpenID: OpenID,
Portrait: Portrait,
Region: Region,
dialect: dialect,
Mandarin: Mandarin,
worksanswer: 0,
workslike: 0,
}
}.) the then (RES => { // successfully update a field in another data
const can = db.collection(‘personalInformation’).doc(openId).update({
data: {
works: _.inc(1)
}
}).then(res => {
return res.stats.updated;
});
return can;
});
return receive;
}
最后返回值

Guess you like

Origin blog.csdn.net/weixin_43365995/article/details/88840596