{"issue":{"state":"closed","pull_request":{"diff_url":null,"html_url":null,"patch_url":null},"user":{"avatar_url":"https://secure.gravatar.com/avatar/bf5d04e2730d431247eeeb765df44f17?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","gravatar_id":"bf5d04e2730d431247eeeb765df44f17","url":"https://api.github.com/users/c4milo","login":"c4milo","id":41681},"milestone":null,"assignee":null,"labels":[],"updated_at":"2011-11-02T22:07:57Z","comments":15,"closed_at":"2011-11-02T20:52:34Z","url":"https://api.github.com/repos/LearnBoost/mongoose/issues/542","body":"I'm trying to delete an element from an internal array in a document. In mongo shell it works okay but not with mongoose. \r\n\r\n/**\r\n * Embedded document\r\n */\r\n\r\nvar Foo = new Schema({\r\n    foo_id : { type: String, required: true, set: toLower },\r\n    user_id     : { type: String, required: true, set: toLower },\r\n    foo_type        : { type: String, enum: ['type1', 'type2'], set: toLower}\r\n});\r\n\r\n\r\n/**\r\n* Main document\r\n*/\r\n\r\nvar Bar = new Schema({\r\n    id          : { type: String, index: {unique: true}, set: toLower },\r\n    name        : { type: String, index: true, required: true },\r\n    user_id     : { type: String, index: true, required: true, set: toLower},\r\n    description : { type: String},\r\n    foos  : [ Foo ]\r\n});\r\n\r\n\r\n*This works in mongo shell: \r\ndb.bars.update({id: '123'}, {$pull: {foos: { foo_id: '456', foo_type: 'type1'}}});\r\n\r\n*with Mongoose I did the following but it didn't delete the element from the \"foos\" array:\r\n\r\nBarModel.update({id: '123'},\r\n{$pull: {foos: { foo_id: '456', foo_type: 'type1'}}}, \r\nfunction(error, data) {\r\n        console.log(data); //returns 1\r\n        console.log(error); //returns null\r\n        callback(error, data);\r\n});\r\n\r\n\r\n","html_url":"https://github.com/LearnBoost/mongoose/issues/542","number":542,"title":"$pull doesn't work with an array of embedded documents.","id":1745703,"created_at":"2011-09-26T20:05:07Z"},"action":"created","comment":{"user":{"avatar_url":"https://secure.gravatar.com/avatar/bf5d04e2730d431247eeeb765df44f17?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","gravatar_id":"bf5d04e2730d431247eeeb765df44f17","url":"https://api.github.com/users/c4milo","login":"c4milo","id":41681},"updated_at":"2011-11-02T22:07:57Z","url":"https://api.github.com/repos/LearnBoost/mongoose/issues/comments/2610510","body":"indeed, we'd be fucked up without you @aheckmann","id":2610510,"created_at":"2011-11-02T22:07:57Z"}}