• 微信小程序云数据库 模糊查询 or和and 使用


    原文:https://blog.csdn.net/qq_29384639/article/details/97150340

    解释:
    db.RegExp

    从基础库 2.3.2 开始(wx-server-sdk 从 0.0.23 开始),数据库支持正则表达式查询,开发者可以在查询语句中使用 JavaScript 原生正则对象或使用 db.RegExp 方法来构造正则对象然后进行字符串匹配。在查询条件中对一个字段进行正则匹配即要求该字段的值可以被给定的正则表达式匹配

     事例:

    search(e, val) {
                    const _this = this
                    this.screenName = e
                    const db = wx.cloud.database({env: '环境ID'})
                    const _ = db.command
                    db.collection('person').where(_.or([
                      {
                        name:db.RegExp({
                            regexp:e,
                            option:'i'
                        })
                      },
                      {
                        person:db.RegExp({
                            regexp:e,
                            option:'i'
                        })
                      },
                      {
                        location:db.RegExp({
                            regexp:e,
                            option:'i'
                        })
                      }
                    ]).and([{
                        del:0
                    }])).get({
                        success: function(res) {
                            _this.list = res.data
                        }
                    })
                },

    上面.or中条件为或,.and条件中并列满足。

  • 相关阅读:
    Bessie Goes Moo
    小P的强力值
    Max Flow
    约瑟夫
    Moocryption
    杂务
    排行榜
    银行贷款
    轰炸
    Contaminated Milk
  • 原文地址:https://www.cnblogs.com/Sincerity/p/11439820.html
Copyright © 2020-2023  润新知