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()
传关键字匹配不上,是哪里写的有问题吗
q***@126.com (作者)
阿里云
2025-03-01 12:39