getList:function(){
let x = this.data.total
let y = this.data.pageSize
let old_data = this.data.shopList
wx.cloud.callFunction({
name:'twotableQuery',
data:{
collection:'release_Data',
from:'user',
localField:'_openid',
foreignField:'_openid',
as:'seller_id',
match:{
buyer_openid:app.globalData.openid,
buy_status:"交易中"||"交易成功" //我想在这用或,意思是buy_status="交易中"或buy_status="交易成功"
},
sort:{time:-1},
x:x,
y:y
},
success:res=>{
console.log(res)
x=x+y
this.setData({
shopList:old_data.concat(res.result.list),
total:x
})
}
})
}
这是云函数代码
const cloud = require('wx-server-sdk')
cloud.init({ env: cloud.DYNAMIC_CURRENT_ENV }) // 使用当前云环境
const db = cloud.database()
var $=cloud.database().command.aggregate
const _ = db.command
// 云函数入口函数
exports.main = async (event, context) => {
return await db.collection(event.collection).aggregate()
.match(event.match).sort(event.sort).limit(event.y).skip(event.x)
.lookup({
from:event.from,
localField: event.localField,
foreignField: event.foreignField,
as: event.as
})
.end({
success:function(res){
return res;
},
fail(error){
return error;
}
})
}
在云函数里面拼接查询条件 不能传过去
https://developers.weixin.qq.com/miniprogram/dev/wxcloud/reference-sdk-api/database/command/Command.or.html
buyer_openid:app.globalData.openid,
buy_status:_.or(_.eq(“交易中”),_.eq(“交易成功”))
}
我这样试了下也没用