V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
aoscici2000
V2EX  ›  微信

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

  •  
  •   aoscici2000 · Sep 4, 2019 · 2635 views
    This topic created in 2428 days ago, the information mentioned may be changed or developed.
    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 报错)

    这是怎么回事?

    No Comments Yet
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2836 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 34ms · UTC 15:43 · PVG 23:43 · LAX 08:43 · JFK 11:43
    ♥ Do have faith in what you're doing.