微信小程序模糊查询云开发

时间:2021-05-19 10:33:30   收藏:0   阅读:7
    let key = "编程";
    console.log("查询的内容", key)
    const db = wx.cloud.database();
    const _ = db.command
    db.collection(‘qcl‘).where(_.or([{
        name: db.RegExp({
          regexp: ‘.*‘ + key,
          options: ‘i‘,
        })
      },
      {
        address: db.RegExp({
          regexp: ‘.*‘ + key,
          options: ‘i‘,
        })
      }
    ])).get({
      success: res => {
        console.log(res)
      },
      fail: err => {
        console.log(err)
      }
    })
key就是我们要搜索的关键字。主要是用到了数据库查询的where,or,get方法。

技术分享图片

 

原文:https://www.cnblogs.com/lks6/p/14783510.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!