html52.com
我爱小程序-开发者交流社区

数据库条件查询问题?

各位前辈,小弟开发新人,请教一个数据条件查询问题。

使用云函数进行数据库条件查询,wxml 界面用时间picker获取时间,JS 部分定义date并获取picker选定后的值。并把这个值,传到云函数,传值成功。

就是不确定传的值的类型。云开发数据库中记录里,定义的date为string类型。用where进行条件查询。

如:picker 确定2020-05-20,传值到云函数为2020-05-20,数据库集合里有记录中含有date 为2020-05-20的数据,但是一直查询不到数据,请大神们指点一二。

关键代码:WXML就不写了,比较简单的picker组件。

JS:

getResource(res){

    console.log("点击有效")

    wx.cloud.callFunction({

      name:"getVolumebanlance",

      data:{

        date:this.data.date

           }

       })  

        .then(res=>{

          console.log(res)

        }).catch(res=>{

          console.log("查询数据失败")

        })

    }

云函数:

exports.main = async (event) => {

  // return event.date

  var date=event.date

  return await DB.collection("Volume_Balance").where({

    date: date

  }).get()

    

}





网友回复

binnie smile:

查询语句把参数写死能查出来吗?

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

真正的个人免签约支付接口

云免签H5支付