{"action":"created","issue":{"url":"https://api.github.com/repos/Automattic/mongoose/issues/3021","labels_url":"https://api.github.com/repos/Automattic/mongoose/issues/3021/labels{/name}","comments_url":"https://api.github.com/repos/Automattic/mongoose/issues/3021/comments","events_url":"https://api.github.com/repos/Automattic/mongoose/issues/3021/events","html_url":"https://github.com/Automattic/mongoose/issues/3021","id":81701122,"number":3021,"title":"findOneAndUpdate with $pull not removing","user":{"login":"damionjn","id":7221494,"avatar_url":"https://avatars.githubusercontent.com/u/7221494?v=3","gravatar_id":"","url":"https://api.github.com/users/damionjn","html_url":"https://github.com/damionjn","followers_url":"https://api.github.com/users/damionjn/followers","following_url":"https://api.github.com/users/damionjn/following{/other_user}","gists_url":"https://api.github.com/users/damionjn/gists{/gist_id}","starred_url":"https://api.github.com/users/damionjn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/damionjn/subscriptions","organizations_url":"https://api.github.com/users/damionjn/orgs","repos_url":"https://api.github.com/users/damionjn/repos","events_url":"https://api.github.com/users/damionjn/events{/privacy}","received_events_url":"https://api.github.com/users/damionjn/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/Automattic/mongoose/labels/can't%20reproduce","name":"can't reproduce","color":"bfdadc"}],"state":"closed","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/Automattic/mongoose/milestones/44","html_url":"https://github.com/Automattic/mongoose/milestones/4.0.6","labels_url":"https://api.github.com/repos/Automattic/mongoose/milestones/44/labels","id":1138399,"number":44,"title":"4.0.6","description":"","creator":{"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},"open_issues":10,"closed_issues":15,"state":"open","created_at":"2015-05-28T16:29:51Z","updated_at":"2015-06-16T14:59:52Z","due_on":"2015-06-19T04:00:00Z","closed_at":null},"comments":2,"created_at":"2015-05-28T01:21:29Z","updated_at":"2015-06-16T14:59:52Z","closed_at":"2015-06-16T14:59:52Z","body":"The promise is resolving and I'm able to send the entity back to the client, yet it's unmodified. It doesn't work with a callback either. This was working with v3.8.19, currently using 4.0.3.\r\n```js\r\nEntity.findOneAndUpdate(\r\n  { accountId: _id },\r\n  { $pull: { categories: { _id: categoryId }}}).exec()\r\n  .then(function (entity) {\r\n    res.send(entity)\r\n  }, function (err) {\r\n    res.status(500).end('Couldn\\'t save entity: ' + err)\r\n  })\r\n```\r\n\r\nI *am* able to modify categories with the following:\r\n```js\r\nEntity.findOneAndUpdate(\r\n  { accountId: _id },\r\n  { categories: null },\r\n  { upsert: true }).exec()\r\n  .then(function (entity) {\r\n    res.send(entity)\r\n  }, function (err) {\r\n    res.status(500).end('Couldn\\'t save entity: ' +  err)\r\n  })\r\n```\r\n\r\nExample entity (not deeply nested):\r\n```js\r\n{\r\n  _id: 057023749273asdf,\r\n  profiles: [\r\n    { _id: 057023749273asdff, name: 'profile1' },\r\n    { _id: 057023749273asdfff, name: 'profile2' },\r\n  ],\r\n  categories: [\r\n    { _id: 057023749273asdffff, name: 'cat1', subcategories: [Object] },\r\n    { _id: 057023749273asdfffff, name: 'cat2', subcategories: [Object] },\r\n  ]\r\n}\r\n```"},"comment":{"url":"https://api.github.com/repos/Automattic/mongoose/issues/comments/112462046","html_url":"https://github.com/Automattic/mongoose/issues/3021#issuecomment-112462046","issue_url":"https://api.github.com/repos/Automattic/mongoose/issues/3021","id":112462046,"user":{"login":"damionjn","id":7221494,"avatar_url":"https://avatars.githubusercontent.com/u/7221494?v=3","gravatar_id":"","url":"https://api.github.com/users/damionjn","html_url":"https://github.com/damionjn","followers_url":"https://api.github.com/users/damionjn/followers","following_url":"https://api.github.com/users/damionjn/following{/other_user}","gists_url":"https://api.github.com/users/damionjn/gists{/gist_id}","starred_url":"https://api.github.com/users/damionjn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/damionjn/subscriptions","organizations_url":"https://api.github.com/users/damionjn/orgs","repos_url":"https://api.github.com/users/damionjn/repos","events_url":"https://api.github.com/users/damionjn/events{/privacy}","received_events_url":"https://api.github.com/users/damionjn/received_events","type":"User","site_admin":false},"created_at":"2015-06-16T14:59:52Z","updated_at":"2015-06-16T14:59:52Z","body":"Thanks @vkarpov15 "}}