{"action":"created","issue":{"url":"https://api.github.com/repos/Automattic/mongoose/issues/6439","repository_url":"https://api.github.com/repos/Automattic/mongoose","labels_url":"https://api.github.com/repos/Automattic/mongoose/issues/6439/labels{/name}","comments_url":"https://api.github.com/repos/Automattic/mongoose/issues/6439/comments","events_url":"https://api.github.com/repos/Automattic/mongoose/issues/6439/events","html_url":"https://github.com/Automattic/mongoose/issues/6439","id":321450319,"number":6439,"title":"[BUG] $pull + $in remove all embedded documents in an array type field.","user":{"login":"FrostyLeaf","id":8349568,"avatar_url":"https://avatars1.githubusercontent.com/u/8349568?v=4","gravatar_id":"","url":"https://api.github.com/users/FrostyLeaf","html_url":"https://github.com/FrostyLeaf","followers_url":"https://api.github.com/users/FrostyLeaf/followers","following_url":"https://api.github.com/users/FrostyLeaf/following{/other_user}","gists_url":"https://api.github.com/users/FrostyLeaf/gists{/gist_id}","starred_url":"https://api.github.com/users/FrostyLeaf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/FrostyLeaf/subscriptions","organizations_url":"https://api.github.com/users/FrostyLeaf/orgs","repos_url":"https://api.github.com/users/FrostyLeaf/repos","events_url":"https://api.github.com/users/FrostyLeaf/events{/privacy}","received_events_url":"https://api.github.com/users/FrostyLeaf/received_events","type":"User","site_admin":false},"labels":[{"id":28988582,"url":"https://api.github.com/repos/Automattic/mongoose/labels/confirmed-bug","name":"confirmed-bug","color":"e10c02","default":false}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2018-05-09T06:48:00Z","updated_at":"2018-05-09T18:59:01Z","closed_at":"2018-05-09T14:38:50Z","author_association":"NONE","body":"**Node Version**: 8.9.4\r\n\r\n**Mongoose Version**: 5.0.17; 4.13.12\r\n\r\n**Mongodb Version**: 3.2.9\r\n\r\nThis is how to reproduce this bug:\r\n\r\n```js\r\nconst mongoose = require('mongoose');\r\n\r\nmongoose.connect('mongodb://localhost/test', {debug: true});\r\nmongoose.set('debug', true);\r\n\r\nconst Cat = mongoose.model('Cat', {\r\n  name: String,\r\n  props: [\r\n    new mongoose.Schema(\r\n      {\r\n        name: String\r\n      },\r\n      {_id: false}\r\n    )\r\n  ]\r\n});\r\n\r\n(async function () {\r\n  let kitty = new Cat({name: 'Zildjian',\r\n    props: [\r\n      {name: 'invalid'},\r\n      {name: 'abc'},\r\n      {name: 'def'}\r\n    ]\r\n  });\r\n  await kitty.save();\r\n\r\n  kitty = await Cat.findById(kitty._id);\r\n  console.log(kitty.props);\r\n\r\n  // The setter is casted as `{ '$pull': { props: {} } }`, which leads the all embedded documents of `props` field to be removed.\r\n  await Cat.update({_id: kitty._id}, {$pull: {props: {$in: [{name: 'invalid'}, {name: 'def'}]}}});\r\n\r\n  kitty = await Cat.findById(kitty._id);\r\n  console.log('result:', kitty.props); // Expect an array with 1 embedded document inside, but get 0 here.\r\n}());\r\n\r\n```\r\n\r\n**Expected Behavior**: `$pull` + `$in` should only remove the embedded documents match the assigned conditions, not all of them."},"comment":{"url":"https://api.github.com/repos/Automattic/mongoose/issues/comments/387841413","html_url":"https://github.com/Automattic/mongoose/issues/6439#issuecomment-387841413","issue_url":"https://api.github.com/repos/Automattic/mongoose/issues/6439","id":387841413,"user":{"login":"FrostyLeaf","id":8349568,"avatar_url":"https://avatars1.githubusercontent.com/u/8349568?v=4","gravatar_id":"","url":"https://api.github.com/users/FrostyLeaf","html_url":"https://github.com/FrostyLeaf","followers_url":"https://api.github.com/users/FrostyLeaf/followers","following_url":"https://api.github.com/users/FrostyLeaf/following{/other_user}","gists_url":"https://api.github.com/users/FrostyLeaf/gists{/gist_id}","starred_url":"https://api.github.com/users/FrostyLeaf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/FrostyLeaf/subscriptions","organizations_url":"https://api.github.com/users/FrostyLeaf/orgs","repos_url":"https://api.github.com/users/FrostyLeaf/repos","events_url":"https://api.github.com/users/FrostyLeaf/events{/privacy}","received_events_url":"https://api.github.com/users/FrostyLeaf/received_events","type":"User","site_admin":false},"created_at":"2018-05-09T18:59:01Z","updated_at":"2018-05-09T18:59:01Z","author_association":"NONE","body":"So, when v5.0.18 will be published, please? And will you guys fix this on v4?"}}
{"actor":{"display_login":"FrostyLeaf"}}