微信小程序模糊查詢雲開發


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

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM