`
wang_peng1
  • 浏览: 3954767 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

更新数组中的一个值

 
阅读更多
{
 students: [
              { name: "john", school: 102, age: 4 },
              { name: "jess", school: 102, age: 11 },
              { name: "jeff", school: 108, age: 7 }
           ]
}
{
 students: [
              { name: "ajax", school: 100, age: 7 },
              { name: "achilles", school: 100, age: 8 },
           ]
}
{
 students: [
              { name: "bob", school: 100, age: 7 },
              { name: "manuel", school: 100, age: 8 },
           ]
}

更新7age=7的 school 为101
db.students.update({"students.age":7},{$set: {"students.$.school":101}},true,true)
 
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics