云开发多表联合查询的问题
- 不知道算不算bug,在get数据库后的then里面在根据查询的sid查询另一张表,把数据放到原来的属性,但无法访问到。
文章列表与文章评论,根据文章列表id查询评论数或评论,想过用云函数,但云函数调用次数担心有超出,所以想请教一下有没有其他方法
db.collection('article') .where({ ispublic: true }) .limit(16) .get() .then(res => { res.data.forEach((item, index) => { db.collection('commit') .where({ sid: item._id }) .count() .then(comitres => { item.commitNum = comitres.total return item }) return item }) console.info("111", res) //这里控制台输出能看到commitNum 属性 return res }) .then(rres => { console.info("最终返回的数据", rres) //这里控制台输出能看到commitNum 属性,但视图层没更新 this.setData({ lists: rres.data }) }) |
