个人案例
- 搜衣鸡 shouyiji
搜索欧美外贸女装并可下载
搜衣鸡 souyiji扫码体验
[代码]const _ = db.command[代码][代码]let re = [代码][代码]new[代码] [代码]RegExp(event.word, [代码][代码]"i"[代码][代码])[代码][代码]let data = await db.collection([代码][代码]'user'[代码][代码]).where([代码][代码] [代码][代码]_.or([{[代码][代码] [代码][代码]openId: re[代码][代码] [代码][代码]}, {[代码][代码] [代码][代码]'userInfo.nickName'[代码][代码]: re[代码][代码] [代码][代码]}])[代码][代码] [代码][代码])[代码][代码] [代码][代码].get()[代码]
请问如果实现多条件云函数查询数据库?我想先查询用户的openid然后再跨字段进行 "或" 操作,所以我用了.where().where()的方式,但是感觉很不规范,请问如何才能优化只有一个where()呢? [代码]let w = [],[代码][代码] [代码][代码]id = {}[代码][代码] [代码][代码]if[代码] [代码](keyword.trim() != [代码][代码]''[代码][代码]) {[代码][代码] [代码][代码]w = [{[代码][代码] [代码][代码]ar: db.RegExp({[代码][代码] [代码][代码]regexp: keyword,[代码][代码] [代码][代码]options: [代码][代码]'i'[代码][代码] [代码][代码]})[代码][代码] [代码][代码]},[代码][代码] [代码][代码]{[代码][代码] [代码][代码]name: db.RegExp({[代码][代码] [代码][代码]regexp: keyword,[代码][代码] [代码][代码]options: [代码][代码]'i'[代码][代码] [代码][代码]})[代码][代码] [代码][代码]}[代码][代码] [代码][代码]][代码][代码] [代码][代码]}[代码][代码] [代码][代码]id = {[代码][代码] [代码][代码]_openid: wxContext.OPENID[代码][代码] [代码][代码]}[代码][代码] [代码][代码]//先获取openid 然后再进行条件搜索,条件搜索数组不能为空,所以进行了一个判断[代码][代码] [代码][代码]if[代码] [代码](w.length != 0) {[代码][代码] [代码][代码]ctx.body = await cloud.database().collection([代码][代码]'collectMusiclist'[代码][代码]).where(id).where(_.or(w)).skip(event.start).limit(event.count)[代码][代码] [代码][代码].orderBy([代码][代码]'createTime'[代码][代码], [代码][代码]'desc'[代码][代码])[代码][代码] [代码][代码].get().then(res => {[代码][代码] [代码][代码]return[代码] [代码]res[代码][代码] [代码][代码]})[代码][代码] [代码][代码]} [代码][代码]else[代码] [代码]{[代码][代码] [代码][代码]ctx.body = await cloud.database().collection([代码][代码]'collectMusiclist'[代码][代码]).where({[代码][代码] [代码][代码]_openid: wxContext.OPENID[代码][代码] [代码][代码]}).skip(event.start).limit(event.count)[代码][代码] [代码][代码].orderBy([代码][代码]'createTime'[代码][代码], [代码][代码]'desc'[代码][代码])[代码][代码] [代码][代码].get().then(res => {[代码][代码] [代码][代码]return[代码] [代码]res[代码][代码] [代码][代码]})[代码][代码] [代码][代码]}[代码]新手一枚,想请各位大佬解答一下
2019-11-23啥也没用,裸奔
大家都用什么框架来开发小程序?经常在群里 有朋友问起,大家都用什么框架,那么咱大家一起投票吧,用数据说话,也不是说哪个最欢迎,就是单纯我们用过哪个框架 常见框架下面有介绍 https://developers.weixin.qq.com/community/develop/article/doc/000226d7d489f8ec92793262556013 [图片] 投票不是说选哪个最欢迎,就是单纯统计我们用过哪个框架,方便为一些在框架选择上有选择性障碍的同学提供帮助。
2019-11-21