收藏
回答

数据库.all操作符和描述不相符

框架类型小程序
问题类型Bug
终端类型微信安卓客户端
AppIDwx3d4018496dbb74f8
环境IDstartup-3geim7nw7dca24b5
基础库版本3.8.7
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中的数据库查询也不一致?


回答关注问题邀请回答
收藏

2 个回答

请 登录 后发表内容