aoscici2000
V2EX  ›  微信

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

  •  
  •   aoscici2000 · Sep 4, 2019 · 2760 views
    This topic created in 2500 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   ·   5653 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 34ms · UTC 03:15 · PVG 11:15 · LAX 20:15 · JFK 23:15
    ♥ Do have faith in what you're doing.