9***@qq.com
9***@qq.com
  • 发布:2025-08-19 19:47
  • 更新:2025-08-20 10:26
  • 阅读:64

unicloud支付宝云数据库用in指令查询_id字段查不到数据

分类:uniCloud

官方文档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要怎么做?用||和==拼接吗?

2025-08-19 19:47 负责人:无 分享
已邀请:
DCloud_uniCloud_CRL

DCloud_uniCloud_CRL

哪个云厂商?

要回复问题请先登录注册