小白求问,云数据库中怎查询某个字段值中是否包含“张三”
发布于 5 年前 作者 xia25 1324 次浏览 来自 问答
  • 需求的场景描述(希望解决的问题)
  • 希望提供的能力

云数据库中怎查询某个字段值中是否包含“张三”。

我又一个name字段,想查出,所有叫“张三丰” “刘张三”,“张三傻”等等。

如何写这个语句呢?

db.collection(‘student’).where({

//请问这里怎么写才可以?

name: “???张三???” ,

}).get({

success(res) {

console.log(res.data)

}

})

1 回复

https://developers.weixin.qq.com/miniprogram/dev/wxcloud/reference-client-api/database/db.regexp.html

   db.collection(‘student’).where({

      name:{

        $regex:’.*’+ ‘张三’

      }

    }).get({

 

        success(res) {

        

        console.log(res.data)

        

        }

     });

没试验过,云开发后期维护有问题,所以没用云开发

回到顶部