云函数数据库查询,加了match方法后为什么就不work?

发布于 7 年前作者 yangliu7450 次浏览最后编辑 7 年前来自 issues

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

cloud.init()

const db = cloud.database()

const _ = db.command

const $ = _.aggregate

// 云函数入口函数

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

return db.collection(‘orders’)

.aggregate()

.match({

status: _.neq(-1)

})

.sort({

addTime: -1

})

.end()

}

请教这个数据库查询云函数,没有加match方法可以输出数据,加了match就得不到数据,哪里写的有问题?相同的写法在客户端都可以正常执行。谢谢!

3 回复
xiuying57
xiuying571 楼6 年前

目测status: _.neq(-1)应该改为:status: $.neq(-1)

na10
na103 楼5 年前

你已经赋值为$了,不是神奇,你用错对象啦 兄弟