const collectionName = 'jzb-book-cost';
const collectionUser = "uni-id-users";
const dbCmd = db.command;
let condition = {
book_id: dbCmd.eq("f380561066bd5b0906fdba5e3b9b7bc3"),
del_flag: 0,
user_id: dbCmd.eq("ef45322e66b193d805ca8cce15e57035")
}
//用户信息作为关联
const userInfo = db.collection(collectionUser).field("nickname,_id").getTemp();
//费用明细关联
const costDetail = db.collection(collectionName).where(condition)
.field(
'name,book_id,type,cost_type_name,cost_type_img,user_name,user_id,cost_date,cost_time,money,remark,create_date,del_flag'
).getTemp();
//分页查询数据
db.collection(costDetail, userInfo).where(condition)
.orderBy('cost_date desc,cost_time desc,create_date desc')
.skip((1 - 1) * 10)
.limit(10)
.get({
getCount: true
});
1 个回复
滚滚向前 (作者)
已解决,db.collection(costDetail, userInfo).where(condition)
.orderBy('cost_date desc,cost_time desc,create_date desc')
.skip((1 - 1) * 10)
.limit(10)
.get({
getCount: true
}); 将这里边的condition去掉,因为联表后的user_id已经变成一个数组了,在联表之前已经过滤了,这就不需要加条件了