小程序数据库如何通过一个id列表获取集合中对应多条记录?
发布于 7 年前 作者 yongshao 12322 次浏览 来自 官方Issues

最简单的方法是通过一个循环,重复请求数据库,但是会增加数据库的访问次数

能否通过一个请求就完成

例如

doc.collection(‘someCollection’).doc(<idList>)

这种

1 回复

用where加db.command

var _ =db.command
 
db.collection('collection').where({_id:_.in(idList)}).get()

参考文档 https://developers.weixin.qq.com/miniprogram/dev/wxcloud/reference-client-api/database/command.in.html

回到顶部