q***@126.com
q***@126.com
  • 发布:2025-02-27 13:23
  • 更新:2025-02-28 14:54
  • 阅读:126

多字段模糊查询不生效

分类:uniCloud
let matchCondition = {};  
    if (keyword) {  
        const regex = new RegExp(keyword, 'i');  
        matchCondition = {  
            $or: [  
                { name: regex },  
                { phone: regex },  
            ]  
        };  
    }  
    let query = db.collection('q-tenant').aggregate()  
        .match(matchCondition)  
        .lookup({  
            from: 'q-shop',  
            localField: '_id',  
            foreignField: 'tenant_id',  
            as: 'shops'  
        })  
        .addFields({  
            count: {  
                $size: '$shops'  
            }  
        })  
        .project({  
            shops: 0  
        })  
        .sort({ create_date: -1 })  
    let res = await query.end()

传关键字匹配不上,是哪里写的有问题吗

2025-02-27 13:23 负责人:无 分享
已邀请:
DCloud_uniCloud_CRL

DCloud_uniCloud_CRL

哪个云厂商?

要回复问题请先登录注册