官方文档写的:“如需要匹配多个_id的记录,应使用where方法。可以在where方法里用in指令匹配一个包含_id的数组。”
实践了一下好像不行
数据库里有_id为67246e0b89bd27450bf827f4的数据,以它为例
const res = await db.collection('goods').doc("67246e0b89bd27450bf827f4").get();//能查到数据
const res = await db.collection('goods').where('_id=="67246e0b89bd27450bf827f4"').get();//能查到数据
const res = await db.collection('goods').where('_id in ["67246e0b89bd27450bf827f4"]').get();//查不到数据
const res = await db.collection('goods').where({_id: db.command.in(["67246e0b89bd27450bf827f4"])}).get();//也查不到数据
求解答。如果in指令不行的话,查多个_id要怎么做?用||和==拼接吗?

9***@qq.com
- 发布:2025-08-19 19:47
- 更新:2025-08-19 19:47
- 阅读:12
0 个回复