云函数里面能不能用if这些函数呀,是不是要另外用npm加sdk,要加的话应该怎么加,我是个小白,求大佬们教教我
附上我的云函数代码
const cloud = require(‘wx-server-sdk’)
cloud.init()
const db = cloud.database()
const dbID = cloud.database()
exports.main = async(event, context) => {
if (dbID.collection(‘classcadre’).where({openid: event.userInfo.openId}).get().limits) {
return await db.collection(‘counters’).get()
} else {
return -1
}
报错信息
VM680:1 Error: errCode: -404011 cloud function execution error | errMsg: cloud.callFunction:fail requestID 35db9c53-cec6-11e8-a0e1-525400e8849e, cloud function service error code -504002, error message Missing initializer in const declaration; at cloud.callFunction api;