.where 如何实现动态添加查询条件(筛选)?
请问不想写这么多if else 怎么办?
if (params.username == '' && params.company == '' && params.project == '' && params.bigclassname == '') {
wx.cloud.database().collection("demoorder").where({
date: _.gte(new Date(params.startDate)).and(_.lte(new Date(params.endDate)))
})
.skip(len)
.limit(20)
.get({
success(res) {
},
fail(res) {
}
})
} else if (params.username != "" && params.company == "" && params.project == "" && params.bigclassname == "") {
wx.cloud.database().collection("demoorder").where({
date: _.gte(new Date(params.startDate)).and(_.lte(new Date(params.endDate)))
})
.skip(len)
.limit(20)
.get({
success(res) {
},
fail(res) {
}
})
} else if (params.username == "" && params.company != "" && params.project == "" && params.bigclassname == "") {
wx.cloud.database().collection("demoorder").where({
date: _.gte(new Date(params.startDate)).and(_.lte(new Date(params.endDate)))
})
.skip(len)
.limit(20)
.get({
success(res) {
},
fail(res) {
}
})
}else if{}等等