// 可使用js原生正则表达式或者使用小程序云开发里提供的db.RegExp对象
onQuery: function() {
const db = wx.cloud.database()
// 查询当前用户所有的 counters
db.collection('counters').where({
name: new db.RegExp({
//查询字段name的值为pdc-01,pdc-02,pdc-03
// regexp: 'pdc-0[1-3]',
//查询字段name的值含有 pdc-0 的数据
regexp: 'pdc-0',
options: 'i'
})
}).get({
success: res => {
this.setData({
queryResult: JSON.stringify(res.data, null, 2)
})
console.log('[数据库] [查询记录] 成功: ', res)
},
fail: err => {
wx.showToast({
icon: 'none',
title: '查询记录失败'
})
console.error('[数据库] [查询记录] 失败:', err)
}
})
}