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方法。

 

posted on 2021-05-19 05:02  sunny-cf  阅读(1181)  评论(0)    收藏  举报