API:_.eq()操作符命令(Command)作为event参数,传入云函数准备调用时,其值为空?
发布于 4 年前 作者 jdeng 4558 次浏览 来自 问答

原始诉求:

将 “_.eq()” 的 Command 相关的API调用(我预期的 操作运算符)作为value,与其对应的key作为对象,通过event对象的参数,传入到相应的云函数中,最终预期能在云函数中的event对象中拿到对应的参数值,再进行 lookup 的联表查询。

在此过程中,似乎 - key : “_.eq()” 的 Command 相关的API调用 的键值对对象,无法预期传入到云函数中,而 “$.eq()” 则能够顺利正确传递。

问题描述:

不知是否我的使用方式不当,亦或是 “_.eq()” 的 Command 相关的API使用方式不支持其作为对象参数,在云函数的调用中进行引用?

测试过程:

Command.eq:

//Test for "match" $ command 
  testMatchCommand() {
    wx.cloud.callFunction({
      name "testCommand",
      data : {
        matchCondition : {
          identityID : _.eq(1),
          //identityID : $.eq(1),
        }
      }
    })
    .then(res => {
      console.log("==========testCommand : 返回结果原始数据:" + res.result);
    });
  },

现象描述:如我的测试表结果来看,键值对对象作为match的条件,并未起到过滤作用:identity : _.eq(1),并且 event.matchCondition 参数为空

AggregatedCommand.eq:

//Test for "match" $ command 
  testMatchCommand() {
    wx.cloud.callFunction({
      name : "testCommand",
      data : {
        matchCondition : {
          //identityID : _.eq(1),
          identityID : $.eq(1),
        }

        //  fieldName : 'identityID',
        //  value : 1
      }
    })
    .then(res => {
      console.log("==========testCommand : 返回结果原始数据:" + res.result);
    });
  },

现象描述:基于同样的表,字段,查询条件,相比于 “_.eq()” API的调用,"$.eq()" 的 AggregatedCommand.eq API可以进行传递,但由于 match API 的使用限制:注意 match 阶段和其他聚合阶段不同,不可使用聚合操作符,只能使用查询操作符

https://developers.weixin.qq.com/miniprogram/dev/wxcloud/reference-sdk-api/database/aggregate/Aggregate.match.html#%E7%A4%BA%E4%BE%8B

其亦无法对联表查询的结果进行过滤,甚至无法得到预期包含数据的结果集

相关API

API:https://developers.weixin.qq.com/miniprogram/dev/wxcloud/reference-sdk-api/database/command/Command.eq.html

回到顶部