{"action":"created","issue":{"url":"https://api.github.com/repos/Automattic/mongoose/issues/2348","labels_url":"https://api.github.com/repos/Automattic/mongoose/issues/2348/labels{/name}","comments_url":"https://api.github.com/repos/Automattic/mongoose/issues/2348/comments","events_url":"https://api.github.com/repos/Automattic/mongoose/issues/2348/events","html_url":"https://github.com/Automattic/mongoose/issues/2348","id":44994180,"number":2348,"title":"removing parent document does not call embedded documents pre('remove' middleware","user":{"login":"barroudjo","id":7458434,"avatar_url":"https://avatars.githubusercontent.com/u/7458434?v=3","gravatar_id":"","url":"https://api.github.com/users/barroudjo","html_url":"https://github.com/barroudjo","followers_url":"https://api.github.com/users/barroudjo/followers","following_url":"https://api.github.com/users/barroudjo/following{/other_user}","gists_url":"https://api.github.com/users/barroudjo/gists{/gist_id}","starred_url":"https://api.github.com/users/barroudjo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/barroudjo/subscriptions","organizations_url":"https://api.github.com/users/barroudjo/orgs","repos_url":"https://api.github.com/users/barroudjo/repos","events_url":"https://api.github.com/users/barroudjo/events{/privacy}","received_events_url":"https://api.github.com/users/barroudjo/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/Automattic/mongoose/labels/enhancement","name":"enhancement","color":"02d7e1"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":8,"created_at":"2014-10-06T15:05:46Z","updated_at":"2015-09-02T16:45:03Z","closed_at":null,"body":"Given a simple embedded document scheme like this one:\r\n```\r\nvar answersSchema = new Schema({\r\n    answerer: { type: Schema.Types.ObjectId, ref: 'User' },\r\n    answersList: [{index: Number, value: Number}]\r\n});\r\n\r\nanswersSchema.pre('remove', function (next) {\r\n    console.log('went through \"remove\" middleware for embedded doc !');\r\n});\r\n\r\nvar questionnaireSchema = new Schema({\r\n    name: String,\r\n    answers: [answersSchema],\r\n});\r\n```\r\n\r\nI would expect that calling: \r\n```\r\nQuestionnaire.find({name: 'test'}, function (err, questionnaire) {\r\n    questionnaire.remove(function (err) {\r\n        console.log('removed questionnaire');\r\n    });\r\n});\r\n```\r\nwould get the pre('remove' middleware defined above for the embedded doc called. But it does not. Is this a bug or normal behavior ?"},"comment":{"url":"https://api.github.com/repos/Automattic/mongoose/issues/comments/137165286","html_url":"https://github.com/Automattic/mongoose/issues/2348#issuecomment-137165286","issue_url":"https://api.github.com/repos/Automattic/mongoose/issues/2348","id":137165286,"user":{"login":"vkarpov15","id":1620265,"avatar_url":"https://avatars.githubusercontent.com/u/1620265?v=3","gravatar_id":"","url":"https://api.github.com/users/vkarpov15","html_url":"https://github.com/vkarpov15","followers_url":"https://api.github.com/users/vkarpov15/followers","following_url":"https://api.github.com/users/vkarpov15/following{/other_user}","gists_url":"https://api.github.com/users/vkarpov15/gists{/gist_id}","starred_url":"https://api.github.com/users/vkarpov15/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vkarpov15/subscriptions","organizations_url":"https://api.github.com/users/vkarpov15/orgs","repos_url":"https://api.github.com/users/vkarpov15/repos","events_url":"https://api.github.com/users/vkarpov15/events{/privacy}","received_events_url":"https://api.github.com/users/vkarpov15/received_events","type":"User","site_admin":false},"created_at":"2015-09-02T16:45:03Z","updated_at":"2015-09-02T16:45:03Z","body":"No progress yet."}}