2014-02-14 2 views
0

내가 하위 중첩 된 문서의 n 번째 요소를 업데이트 할 필요가있는 n 번째 요소 :이 구조가 :업데이트 하위 중첩 된 문서 MongoDB를

{ 
    "_id" : ObjectId("52fdbbb470c68c3c14d60700"), 
    "curations" : [{ 

     "measurements" : 
     [ 
     { 
      "_id" : ObjectId("52fdbbb470c68c3c14d80700"), 
      "name" : "GSM15729", 
      "Vals" : ["N/A", "bronchus, lung", "bronchial epithelial cell", "N/A", "N/A", "N/A", "non-smoker", "GPL96"] 
     }, 
     { 
      "_id" : ObjectId("52fdbbb470c68c3c14d90700"), 
      "name" : "GSM104072", 
      "Vals" : ["N/A", "bronchus, lung", "bronchial epithelial cell", "N/A", "N/A", "N/A", "current smoker", "GPL96"] 
     } 

     ] 

    }] 
} 

을 그리고 예를 들어 4 "N을 업데이트 할/내가 명령 줄이 코드 시도했지만 당신의 도움에 대한

db.Series.find({"curations.measurements._id":new ObjectId("52fdbbb470c68c3c14d90700")}, 
    { $set: { 
     "curations.measurements.$.Vals.4": "new_value" 
     } 
}); 

감사를 작동하지 보인다

발스 "A"의 마지막 서브 배열 (5 위치) "!

답변

0

마지막으로 나는 (배열)

db.Series.find({"curations.0.measurements._id":new ObjectId("52fdbbb470c68c3c14d90700")}, 
    { $set: { 
     "curations.0.measurements.$.Vals.4": "new_value" <=In this line 
     } 
}); 
그냥 0을 잊고, 오류 발견
관련 문제