大家好。我正在寻找在猫鼬中使用 Model.find() 方法的文档:
ChamWord
.find({
word: {
$regex: body.searchValue,
$options: 'i',
},
})
而且我还可以通过使用 lookup () 方法添加子文档来进行聚合:
ChamWord.lookup({
from: 'ruwords',
localField: 'wordId',
foreignField: 'translateId',
as: 'translation',
})
但是我无法将这两种方法结合起来,也不知道该怎么做。我需要在搜索之后,就像在第一个代码片段中一样,我立即进行聚合,就像在第二个代码片段中一样,然后才接收数据。
用 $match 解决的问题: