微信小程序实现云数据更新发订阅消息怎样实现?
怎样把查询出来的数据,写到subscribeMessage.send中?
const cloud = require('wx-server-sdk')
cloud.init({
env:
})
const db= cloud.database()
const conm = db.command
exports.main = async (event, context) => {
try {
db.collection("xxxx1").where(
conm.and([
{
ff:2222
},
{
zz:1111
},
])
)
.count()
.then(res => {
console.log(res);
var leng=res.total
const result = await cloud.openapi.subscribeMessage.send({
touser:'xxxxxxxxxxxxxxxxxxxxxx',
data: {
thing4: {
value:leng //不能用-----------leng获取不了
},
date3: {
value: '456'
},
},
templateId: 'INxxxxxxxxxxxxxxxxxxxxxxxxxY',
miniprogramState: 'developer'
})
return result
} catch (err) {
return err
}
})
}
}