const match7 = await db.collection('user')
.where({
tag_fields: _.elemMatch({
tag_id: "486be3ad6854122903442f646fcc1e4e",
config_id: "dd1eb2b4685418df034c3b4e0f05e728",
value: _.in(['女']),
})
}).limit(10)
.get();
console.log(`match7: ${JSON.stringify(match7.data.length)}`)
const match8 = await db.collection('user')
.where({
tag_fields: _.all([_.elemMatch({
tag_id: "486be3ad6854122903442f646fcc1e4e",
config_id: "dd1eb2b4685418df034c3b4e0f05e728",
value: _.in(['女']),
})])
}).limit(10)
.get();
console.log(`match8: ${JSON.stringify(match8.data.length)}`)
match7是能够正确筛选出结果的。但是match8不能。
按照https://developers.weixin.qq.com/miniprogram/dev/wxcloudservice/wxcloud/reference-sdk-api/database/command/Command.all.html的描述,在只有一个_.eleMatch子元素的时候,有_.all和没有_.all应该是等价的吧?为什么会出现不一致?而且这两段代码在云开发IDE数据库的查询里面其实是没有区别的。看起来代码环境和云开发IDE中的数据库查询也不一致?

请前往链接查看问题回复https://cnb.cool/tencent/cloud/cloudbase/community/-/issues/86
代码环境和云开发IDE中的权限不同,会有区别。
这里的问题是加了_.all就查询不出来了。不加是可以的。
而在IDE里,加和不加都是可以查询出来的。