如何在MongoDB中按条件更新嵌套子文档?

如何在MongoDB中按条件更新嵌套子文档?,mongodb,database,nosql,Mongodb,Database,Nosql,我有以下数据结构: // Journeys collection in MongoDB { "_id" : ObjectId("560feabb682290c218770110"), "title" : "El Camino de Santiago", "messages" : [ { "title" : "The sun is strong!", "text" : "Lorem ipsum and so

我有以下数据结构:

// Journeys collection in MongoDB

{
    "_id" : ObjectId("560feabb682290c218770110"),
    "title" : "El Camino de Santiago",
    "messages" : [ 
        {
            "title" : "The sun is strong!",
            "text" : "Lorem ipsum and something more text goes here",
            "lat" : "-34.5555555",
            "lng" : "23.34455335",
            "_id" : ObjectId("560feabc682290c218770111")
        },
      {
            "title" : "The hike was great",
            "text" : "Lorem ipsum and something more text goes here",
            "lat" : "-34.5555555",
            "lng" : "23.34455335",
            "_id" : ObjectId("560feab9682290c21877010f")
        }
    ],
    "followers" : []
}
如何在此特定旅程中更新消息的
标题
字段,其
\u id
560feab9682290c21877010f

db.journeys.update({'messages.id':  ObjectId("560feab9682290c21877010f")}, {$set: {'messages.$.title': 'New Title'}});