官方文档unicloud>云数据库>通用>云函数通过传统方式操作数据库>获取集合的引用中写的:
“如需要匹配多个_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-20 15:22