[英]Searching in MongoDB database by multiple conditions
我是 mongodb 的新手,有這個問題。 我有這樣的文檔,其中項目是項目 ID 的數組。
[{
"_id": {
"$oid": "62c2e94e65f32725f8f62b79"
},
"project": [1,4,5],
"organization": "test",
"name": "john",
"surname": "doe"
},
{
"_id": {
"$oid": "62c409eb242b0509c4b5d891"
},
"project": [16,2],
"organization": "test1",
"name": "john1",
"surname": "doe1"
}]
為了按組織搜索元素,我使用這個表達式,它工作正常 User.find({organization: {$eq: data.org}}) 如何擴展我的表達式,以便它按組織和項目數組中的特定 ID 進行搜索。 例如,我想查找在組織 Test 中工作並且在 ID 為 16 的項目中工作的用戶。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.