云函数查询数据库报错
发布于 6 年前 作者 yanfeng 3344 次浏览 来自 问答

// 云函数入口文件

const cloud = require(‘wx-server-sdk’)

//cloud.init()

cloud.init({env:“XXXXXXXXXXXX”})

//数据库接口

const db = cloud.database()

// 云函数入口函数

exports.main = async (event, context) => {

let re = await db.collection(‘XXXX’).where({

opid: event.userInfo.openId,

}).field({

_id: false,

mid: false,

mxm: true,

mqx: true

}).get();

return {

ysl:re.data

}

}

这个云函数在云控制台测试报错:

{“errorCode”:1,“errorMessage”:“user code exception caught”,“stackTrace”:"errCode: -502001 database request fail | errMsg: Find Fail:(BadValue) Projection cannot have a mix of inclusion and exclusion.; "}

求大神解决

回到顶部