{"action":"created","issue":{"url":"https://api.github.com/repos/balderdashy/waterline/issues/858","labels_url":"https://api.github.com/repos/balderdashy/waterline/issues/858/labels{/name}","comments_url":"https://api.github.com/repos/balderdashy/waterline/issues/858/comments","events_url":"https://api.github.com/repos/balderdashy/waterline/issues/858/events","html_url":"https://github.com/balderdashy/waterline/issues/858","id":58934974,"number":858,"title":"Remove/save behaving very incorrectly for many-to-many relationship.","user":{"login":"devinivy","id":3150233,"avatar_url":"https://avatars.githubusercontent.com/u/3150233?v=3","gravatar_id":"","url":"https://api.github.com/users/devinivy","html_url":"https://github.com/devinivy","followers_url":"https://api.github.com/users/devinivy/followers","following_url":"https://api.github.com/users/devinivy/following{/other_user}","gists_url":"https://api.github.com/users/devinivy/gists{/gist_id}","starred_url":"https://api.github.com/users/devinivy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/devinivy/subscriptions","organizations_url":"https://api.github.com/users/devinivy/orgs","repos_url":"https://api.github.com/users/devinivy/repos","events_url":"https://api.github.com/users/devinivy/events{/privacy}","received_events_url":"https://api.github.com/users/devinivy/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":9,"created_at":"2015-02-25T17:07:35Z","updated_at":"2015-02-26T18:13:57Z","closed_at":null,"body":"In a rush... I will fill this out more soon.\r\n\r\nBut `remove` with a `save` is basically removing _all_ associated records instead of just those specified.  I'm using sails-mysql, but I've found that the issue lives in waterline itself.  `save` triggers a removal of many-to-many records correctly, but the nested operations for `save`'s implicit `update` is completely destroying all of a person's friends (per example below).  There seems to be a sync of join table data going awry.  I was bummed to see that approach to keeping nested elements up-to-date– it cannot work for non-transactional queries, which waterline does not support.  And it's prone to error when racing against a possibly simultaneous `remove` operation.\r\n\r\n```\r\nperson.friends.remove(1);\r\nperson.save(function() {\r\n    // now person has no friends\r\n});\r\n```\r\n\r\nIf you use many-to-many associations, this affects you!  Would love to get a PR up today.  Workin' on it, but would love some help."},"comment":{"url":"https://api.github.com/repos/balderdashy/waterline/issues/comments/76232810","html_url":"https://github.com/balderdashy/waterline/issues/858#issuecomment-76232810","issue_url":"https://api.github.com/repos/balderdashy/waterline/issues/858","id":76232810,"user":{"login":"particlebanana","id":370260,"avatar_url":"https://avatars.githubusercontent.com/u/370260?v=3","gravatar_id":"","url":"https://api.github.com/users/particlebanana","html_url":"https://github.com/particlebanana","followers_url":"https://api.github.com/users/particlebanana/followers","following_url":"https://api.github.com/users/particlebanana/following{/other_user}","gists_url":"https://api.github.com/users/particlebanana/gists{/gist_id}","starred_url":"https://api.github.com/users/particlebanana/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/particlebanana/subscriptions","organizations_url":"https://api.github.com/users/particlebanana/orgs","repos_url":"https://api.github.com/users/particlebanana/repos","events_url":"https://api.github.com/users/particlebanana/events{/privacy}","received_events_url":"https://api.github.com/users/particlebanana/received_events","type":"User","site_admin":false},"created_at":"2015-02-26T18:13:57Z","updated_at":"2015-02-26T18:13:57Z","body":"@devinivy thanks I'll take a look today. It's pretty big so I'll need to do some testing."}}