// 云函数入口文件
const cloud = require('wx-server-sdk')
cloud.init({
env: cloud.DYNAMIC_CURRENT_ENV
})
const db =cloud.database()
const command=db.command
const aggregate = command.aggregate
// 云函数入口函数//查询name里面含有'徐峥'或者detail里面含有'徐峥'的数据
exports.main = async (event, context) => {
return db.collection('movies').where(
command.or([{
name: db.RegExp({
regexp: '.*' + '徐峥',
options: 'i',
})
},
{
detail: db.RegExp({
regexp: '.*' + '徐峥',
options: 'i',
})
}
])
)
.get()
}
主要使用了 where
or
get
实现了模糊查询