mongoose无字段隐约查询

参数
const val = req.body.val;
const reg = new RegExp(val, 'i');
Model.find({
    $or: [
        { key1: {$regex: reg} },
        { key2: {$regex: reg} },
        { key3: {$regex: reg} }
    ]
}).sort({timestamp: -1}).exec((err, docs) => {
    // do something
})
    原文作者:sourcenode
    原文地址: https://segmentfault.com/a/1190000019322371
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞