{"action":"reopened","issue":{"url":"https://api.github.com/repos/Automattic/mongoose/issues/1204","labels_url":"https://api.github.com/repos/Automattic/mongoose/issues/1204/labels{/name}","comments_url":"https://api.github.com/repos/Automattic/mongoose/issues/1204/comments","events_url":"https://api.github.com/repos/Automattic/mongoose/issues/1204/events","html_url":"https://github.com/Automattic/mongoose/issues/1204","id":8264422,"number":1204,"title":"Model.save() doesn't save embedded arrays","user":{"login":"ograycode","id":1228915,"avatar_url":"https://avatars.githubusercontent.com/u/1228915?v=3","gravatar_id":"","url":"https://api.github.com/users/ograycode","html_url":"https://github.com/ograycode","followers_url":"https://api.github.com/users/ograycode/followers","following_url":"https://api.github.com/users/ograycode/following{/other_user}","gists_url":"https://api.github.com/users/ograycode/gists{/gist_id}","starred_url":"https://api.github.com/users/ograycode/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ograycode/subscriptions","organizations_url":"https://api.github.com/users/ograycode/orgs","repos_url":"https://api.github.com/users/ograycode/repos","events_url":"https://api.github.com/users/ograycode/events{/privacy}","received_events_url":"https://api.github.com/users/ograycode/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":10,"created_at":"2012-11-10T18:43:39Z","updated_at":"2015-05-23T20:52:34Z","closed_at":null,"body":"I have nested arrays of documents, and when I change them and do a .save() on the model it does not save the changes in the nested document.\r\n\r\nHere are my models and schemas (some ommited for brevity):\r\n```javascript\r\nvar Votes = new mongoose.Schema({\r\n\tdate: Date, \r\n\tuser_name: String,\r\n\tis_up: Boolean\r\n});\r\n\r\nvar EventSchema = new mongoose.Schema({\r\n  to_date: Date,\r\n  from_date: Date,\r\n  location: String,\r\n  name: String,\r\n  suggested_by: String,\r\n  description: String,\r\n  users: [EventUser],\r\n  comments: [Comments],\r\n  suggestions: [Event],\r\n  votes: [Votes]\r\n});\r\n\r\nvar Event = mongoose.model('Event', EventSchema);\r\n```\r\nModel before event.save() called:\r\n```\r\n{ \r\n     __v: 1,\r\n    _id: 509e87e583ccbfa00e000004,\r\n    description: 'Pfft',\r\n    from_date: Sun Nov 11 2012 08:00:00 GMT-0500 (EST),\r\n    location: 'Home',\r\n    name: 'Whatever',\r\n    suggested_by: 'No one',\r\n    to_date: Sun Nov 11 2012 00:00:00 GMT-0500 (EST),\r\n    votes: [],\r\n    suggestions: \r\n     [ { users: [],\r\n         comments: [],\r\n         suggestions: [],\r\n         votes: [],\r\n         _id: 509e880883ccbfa00e000005,\r\n         suggested_by: 'Some one',\r\n         to_date: Sun Nov 11 2012 04:00:00 GMT-0500 (EST),\r\n         from_date: Mon Nov 12 2012 00:00:00 GMT-0500 (EST),\r\n         location: 'Home',\r\n         name: 'Football',\r\n         description: 'FOOTBALL!!' } ],\r\n    comments: [],\r\n    users: [] \r\n}\r\n```\r\nThe same object with the nested votes right before ```event.save()``` is called. \r\n```\r\n{\r\n   \"__v\":1,\r\n   \"_id\":\"509e87e583ccbfa00e000004\",\r\n   \"description\":\"Pfft\",\r\n   \"from_date\":\"2012-11-11T13:00:00.000Z\",\r\n   \"location\":\"Home\",\r\n   \"name\":\"Whatever\",\r\n   \"suggested_by\":\"No one\",\r\n   \"to_date\":\"2012-11-11T05:00:00.000Z\",\r\n   \"votes\":[ ],\r\n   \"suggestions\":\r\n      [ {\r\n         \"users\":[],\r\n         \"comments\":[ ],\r\n         \"suggestions\":[ ],\r\n         \"votes\":\r\n            [{\r\n               \"is_up\":true,\r\n               \"date\":\"2012-11-10T18:05:25.796Z\",\r\n               \"user_name\":\"No one\"\r\n            }],\r\n         \"_id\":\"509e880883ccbfa00e000005\",\r\n         \"suggested_by\":\"Some one\",\r\n         \"to_date\":\"2012-11-11T09:00:00.000Z\",\r\n         \"from_date\":\"2012-11-12T05:00:00.000Z\",\r\n         \"location\":\"Home\",\r\n         \"name\":\"Football\",\r\n         \"description\":\"FOOTBALL!!\"\r\n      }],\r\n   \"comments\":[],\r\n   \"users\":[]\r\n}\r\n```\r\n\r\nWhen event.save() is called, no error is thrown, but the nested votes schema inside of the nested events schema is not actually saved. If I use the same overall logic in the top level event object to save a vote, it does work. \r\n\r\nWhen I looked through the code, briefly, it appears that .save() is suppose to be a shortcut for both saving new objects, as well as updating ones that already exist. \r\n\r\nMy hunch is Model.prototype._delta isn't going deep enough to catch all nested objects, https://github.com/LearnBoost/mongoose/blob/master/lib/model.js#L529"}}