javascript - 无法同时过滤查找方法和填充方法中的嵌套记录
问题描述
我正在尝试根据我的 searchKey 过滤掉嵌套记录。例如:患者 - >提供者想要根据 searchKey 一起搜索患者和提供者。
但是,当我使用患者详细信息触发 searchkey 时,它正在工作,但是当我输入与提供者相关的任何关键字(想要搜索提供者)但这次过滤器不起作用时。这是我的代码:
patients = await Patient.find({
$or: [
{ firstName: { $regex: searchKey, $options: "i" } },
{ lastName: { $regex: searchKey, $options: "i" } },
{ socialSecurityNumber: { $regex: searchKey, $options: "i" } },
],
provider: currentUser,
}).populate({ path: "provider", select: "firstName lastName", match : {
$or: [
{lastName: { $regex: searchKey,$options: "i" }},
{firstName: { $regex: searchKey,$options: "i" }},
]
} })
.populate({ path: "gender", select: "name -_id" })
.skip(pageSize * pageNumber - pageSize)
.limit(pageSize).lean();
解决方案
推荐阅读
- php - 将用户限制为一个会话
- c# - 取消数据流 ActionBlock 中的特定任务
- python - python - 如何使用pandas或其他方式从python中的CSV文件中拆分值?
- azure-machine-learning-service - anaconda 的 AML 问题
- r - 官员包 - absolute_path(目标)中的错误
- c# - C# WPF - 绑定到 DataGrid 中的父 ViewModel 不起作用
- c++ - 无法在基于 DFS 的任务排序程序中填充“堆栈”
- python - 用其他值替换数据框中的值
- selenium - 对从 Selenium 中的链接列表打开的多个链接执行测试
- oracle - 如何解决 oracle 触发器的错误绑定变量>?