V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
aoscici2000
V2EX  ›  微信

小程序 云函数 传入查询的键名 无法查询

  •  
  •   aoscici2000 · 2019-09-04 23:30:46 +08:00 · 2187 次点击
    这是一个创建于 1666 天前的主题,其中的信息可能已经有所发展或是发生改变。
    const db = cloud.database()
    const _ = db.command
    
    exports.main = async (event, context) => {
      let key = event.key
    
      return await db.collection(event.collection).where({
          key: _.gt(event.gte).and(_.lt(event.lt))
        }).get()
    
    }
    

    例如我要查价格传入{key: "price" ...}, 没报错, 但返回结果是一个空数组

    where 这里的 key 如果直接写死 price 或者 'price' 都能正常查到数据(直接写 event.key 报错)

    这是怎么回事?

    目前尚无回复
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   3262 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 24ms · UTC 14:16 · PVG 22:16 · LAX 07:16 · JFK 10:16
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.