{"action":"closed","number":8,"pull_request":{"url":"https://api.github.com/repos/mongodb-js/storage-mixin/pulls/8","id":52507848,"html_url":"https://github.com/mongodb-js/storage-mixin/pull/8","diff_url":"https://github.com/mongodb-js/storage-mixin/pull/8.diff","patch_url":"https://github.com/mongodb-js/storage-mixin/pull/8.patch","issue_url":"https://api.github.com/repos/mongodb-js/storage-mixin/issues/8","number":8,"state":"closed","locked":false,"title":"INT-961 collection custom sort order","user":{"login":"rueckstiess","id":99221,"avatar_url":"https://avatars.githubusercontent.com/u/99221?v=3","gravatar_id":"","url":"https://api.github.com/users/rueckstiess","html_url":"https://github.com/rueckstiess","followers_url":"https://api.github.com/users/rueckstiess/followers","following_url":"https://api.github.com/users/rueckstiess/following{/other_user}","gists_url":"https://api.github.com/users/rueckstiess/gists{/gist_id}","starred_url":"https://api.github.com/users/rueckstiess/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rueckstiess/subscriptions","organizations_url":"https://api.github.com/users/rueckstiess/orgs","repos_url":"https://api.github.com/users/rueckstiess/repos","events_url":"https://api.github.com/users/rueckstiess/events{/privacy}","received_events_url":"https://api.github.com/users/rueckstiess/received_events","type":"User","site_admin":false},"body":"In the splice storage backend in storage-mixin, we fetch data from local storage first, populate the collection with the partial data, and then get the password for each of the models of the collection individually. This is because the keytar module doesn't allow fetching all models on a namespace at once, you need to know the exact id.\r\n\r\nNow, when populating the collection with partial data, in this case the ConnectionCollection had a custom comparator method and automatically sorted the items differently than how they were fetched from local storage. This lead to the passwords coming back in a different order than the original models. It then merged the passwords into the wrong models, that's why it seemed that password information wasn't set correctly.\r\n\r\nTo reproduce, one would require\r\n\r\n1. several connections, some with, some without password\r\n2. the insertion order must be different to the connection sort order, that means one would need to favorite/unfavorite connections and connect to some of them until this condition is reached\r\n\r\nA first fix was to disable the sorting when populating the collection with partial data. This worked, but it felt still a little unsafe. A user could pass in `{sort: true}` into a `fetch()` call and overwrite the default option. Therefore, I changed the find() method of the secure storage backend to always return the id of the model along with the password. I then walk through the two arrays manually and make sure to merge the right password with the right model based on their ids.","created_at":"2015-12-03T09:10:19Z","updated_at":"2015-12-03T09:40:03Z","closed_at":"2015-12-03T09:40:03Z","merged_at":"2015-12-03T09:40:03Z","merge_commit_sha":"2d17c981b291c654fc5acc8df8501f28e9cf255f","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/mongodb-js/storage-mixin/pulls/8/commits","review_comments_url":"https://api.github.com/repos/mongodb-js/storage-mixin/pulls/8/comments","review_comment_url":"https://api.github.com/repos/mongodb-js/storage-mixin/pulls/comments{/number}","comments_url":"https://api.github.com/repos/mongodb-js/storage-mixin/issues/8/comments","statuses_url":"https://api.github.com/repos/mongodb-js/storage-mixin/statuses/01d1db46c380bfb8e617072d5dff5d8e0caa4db0","head":{"label":"mongodb-js:INT-961-collection-custom-sort-order","ref":"INT-961-collection-custom-sort-order","sha":"01d1db46c380bfb8e617072d5dff5d8e0caa4db0","user":{"login":"mongodb-js","id":11214950,"avatar_url":"https://avatars.githubusercontent.com/u/11214950?v=3","gravatar_id":"","url":"https://api.github.com/users/mongodb-js","html_url":"https://github.com/mongodb-js","followers_url":"https://api.github.com/users/mongodb-js/followers","following_url":"https://api.github.com/users/mongodb-js/following{/other_user}","gists_url":"https://api.github.com/users/mongodb-js/gists{/gist_id}","starred_url":"https://api.github.com/users/mongodb-js/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mongodb-js/subscriptions","organizations_url":"https://api.github.com/users/mongodb-js/orgs","repos_url":"https://api.github.com/users/mongodb-js/repos","events_url":"https://api.github.com/users/mongodb-js/events{/privacy}","received_events_url":"https://api.github.com/users/mongodb-js/received_events","type":"Organization","site_admin":false},"repo":{"id":47043749,"name":"storage-mixin","full_name":"mongodb-js/storage-mixin","owner":{"login":"mongodb-js","id":11214950,"avatar_url":"https://avatars.githubusercontent.com/u/11214950?v=3","gravatar_id":"","url":"https://api.github.com/users/mongodb-js","html_url":"https://github.com/mongodb-js","followers_url":"https://api.github.com/users/mongodb-js/followers","following_url":"https://api.github.com/users/mongodb-js/following{/other_user}","gists_url":"https://api.github.com/users/mongodb-js/gists{/gist_id}","starred_url":"https://api.github.com/users/mongodb-js/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mongodb-js/subscriptions","organizations_url":"https://api.github.com/users/mongodb-js/orgs","repos_url":"https://api.github.com/users/mongodb-js/repos","events_url":"https://api.github.com/users/mongodb-js/events{/privacy}","received_events_url":"https://api.github.com/users/mongodb-js/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/mongodb-js/storage-mixin","description":"Wrapper to persist Ampersand.js models and collections to various storage backends.","fork":false,"url":"https://api.github.com/repos/mongodb-js/storage-mixin","forks_url":"https://api.github.com/repos/mongodb-js/storage-mixin/forks","keys_url":"https://api.github.com/repos/mongodb-js/storage-mixin/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mongodb-js/storage-mixin/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mongodb-js/storage-mixin/teams","hooks_url":"https://api.github.com/repos/mongodb-js/storage-mixin/hooks","issue_events_url":"https://api.github.com/repos/mongodb-js/storage-mixin/issues/events{/number}","events_url":"https://api.github.com/repos/mongodb-js/storage-mixin/events","assignees_url":"https://api.github.com/repos/mongodb-js/storage-mixin/assignees{/user}","branches_url":"https://api.github.com/repos/mongodb-js/storage-mixin/branches{/branch}","tags_url":"https://api.github.com/repos/mongodb-js/storage-mixin/tags","blobs_url":"https://api.github.com/repos/mongodb-js/storage-mixin/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mongodb-js/storage-mixin/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mongodb-js/storage-mixin/git/refs{/sha}","trees_url":"https://api.github.com/repos/mongodb-js/storage-mixin/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mongodb-js/storage-mixin/statuses/{sha}","languages_url":"https://api.github.com/repos/mongodb-js/storage-mixin/languages","stargazers_url":"https://api.github.com/repos/mongodb-js/storage-mixin/stargazers","contributors_url":"https://api.github.com/repos/mongodb-js/storage-mixin/contributors","subscribers_url":"https://api.github.com/repos/mongodb-js/storage-mixin/subscribers","subscription_url":"https://api.github.com/repos/mongodb-js/storage-mixin/subscription","commits_url":"https://api.github.com/repos/mongodb-js/storage-mixin/commits{/sha}","git_commits_url":"https://api.github.com/repos/mongodb-js/storage-mixin/git/commits{/sha}","comments_url":"https://api.github.com/repos/mongodb-js/storage-mixin/comments{/number}","issue_comment_url":"https://api.github.com/repos/mongodb-js/storage-mixin/issues/comments{/number}","contents_url":"https://api.github.com/repos/mongodb-js/storage-mixin/contents/{+path}","compare_url":"https://api.github.com/repos/mongodb-js/storage-mixin/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mongodb-js/storage-mixin/merges","archive_url":"https://api.github.com/repos/mongodb-js/storage-mixin/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mongodb-js/storage-mixin/downloads","issues_url":"https://api.github.com/repos/mongodb-js/storage-mixin/issues{/number}","pulls_url":"https://api.github.com/repos/mongodb-js/storage-mixin/pulls{/number}","milestones_url":"https://api.github.com/repos/mongodb-js/storage-mixin/milestones{/number}","notifications_url":"https://api.github.com/repos/mongodb-js/storage-mixin/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mongodb-js/storage-mixin/labels{/name}","releases_url":"https://api.github.com/repos/mongodb-js/storage-mixin/releases{/id}","created_at":"2015-11-28T23:51:28Z","updated_at":"2015-11-28T23:54:01Z","pushed_at":"2015-12-03T09:40:04Z","git_url":"git://github.com/mongodb-js/storage-mixin.git","ssh_url":"git@github.com:mongodb-js/storage-mixin.git","clone_url":"https://github.com/mongodb-js/storage-mixin.git","svn_url":"https://github.com/mongodb-js/storage-mixin","homepage":null,"size":98,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"mongodb-js:master","ref":"master","sha":"d257c7fb244d50377d0c268b6f301a53dfccff1b","user":{"login":"mongodb-js","id":11214950,"avatar_url":"https://avatars.githubusercontent.com/u/11214950?v=3","gravatar_id":"","url":"https://api.github.com/users/mongodb-js","html_url":"https://github.com/mongodb-js","followers_url":"https://api.github.com/users/mongodb-js/followers","following_url":"https://api.github.com/users/mongodb-js/following{/other_user}","gists_url":"https://api.github.com/users/mongodb-js/gists{/gist_id}","starred_url":"https://api.github.com/users/mongodb-js/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mongodb-js/subscriptions","organizations_url":"https://api.github.com/users/mongodb-js/orgs","repos_url":"https://api.github.com/users/mongodb-js/repos","events_url":"https://api.github.com/users/mongodb-js/events{/privacy}","received_events_url":"https://api.github.com/users/mongodb-js/received_events","type":"Organization","site_admin":false},"repo":{"id":47043749,"name":"storage-mixin","full_name":"mongodb-js/storage-mixin","owner":{"login":"mongodb-js","id":11214950,"avatar_url":"https://avatars.githubusercontent.com/u/11214950?v=3","gravatar_id":"","url":"https://api.github.com/users/mongodb-js","html_url":"https://github.com/mongodb-js","followers_url":"https://api.github.com/users/mongodb-js/followers","following_url":"https://api.github.com/users/mongodb-js/following{/other_user}","gists_url":"https://api.github.com/users/mongodb-js/gists{/gist_id}","starred_url":"https://api.github.com/users/mongodb-js/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mongodb-js/subscriptions","organizations_url":"https://api.github.com/users/mongodb-js/orgs","repos_url":"https://api.github.com/users/mongodb-js/repos","events_url":"https://api.github.com/users/mongodb-js/events{/privacy}","received_events_url":"https://api.github.com/users/mongodb-js/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/mongodb-js/storage-mixin","description":"Wrapper to persist Ampersand.js models and collections to various storage backends.","fork":false,"url":"https://api.github.com/repos/mongodb-js/storage-mixin","forks_url":"https://api.github.com/repos/mongodb-js/storage-mixin/forks","keys_url":"https://api.github.com/repos/mongodb-js/storage-mixin/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mongodb-js/storage-mixin/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mongodb-js/storage-mixin/teams","hooks_url":"https://api.github.com/repos/mongodb-js/storage-mixin/hooks","issue_events_url":"https://api.github.com/repos/mongodb-js/storage-mixin/issues/events{/number}","events_url":"https://api.github.com/repos/mongodb-js/storage-mixin/events","assignees_url":"https://api.github.com/repos/mongodb-js/storage-mixin/assignees{/user}","branches_url":"https://api.github.com/repos/mongodb-js/storage-mixin/branches{/branch}","tags_url":"https://api.github.com/repos/mongodb-js/storage-mixin/tags","blobs_url":"https://api.github.com/repos/mongodb-js/storage-mixin/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mongodb-js/storage-mixin/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mongodb-js/storage-mixin/git/refs{/sha}","trees_url":"https://api.github.com/repos/mongodb-js/storage-mixin/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mongodb-js/storage-mixin/statuses/{sha}","languages_url":"https://api.github.com/repos/mongodb-js/storage-mixin/languages","stargazers_url":"https://api.github.com/repos/mongodb-js/storage-mixin/stargazers","contributors_url":"https://api.github.com/repos/mongodb-js/storage-mixin/contributors","subscribers_url":"https://api.github.com/repos/mongodb-js/storage-mixin/subscribers","subscription_url":"https://api.github.com/repos/mongodb-js/storage-mixin/subscription","commits_url":"https://api.github.com/repos/mongodb-js/storage-mixin/commits{/sha}","git_commits_url":"https://api.github.com/repos/mongodb-js/storage-mixin/git/commits{/sha}","comments_url":"https://api.github.com/repos/mongodb-js/storage-mixin/comments{/number}","issue_comment_url":"https://api.github.com/repos/mongodb-js/storage-mixin/issues/comments{/number}","contents_url":"https://api.github.com/repos/mongodb-js/storage-mixin/contents/{+path}","compare_url":"https://api.github.com/repos/mongodb-js/storage-mixin/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mongodb-js/storage-mixin/merges","archive_url":"https://api.github.com/repos/mongodb-js/storage-mixin/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mongodb-js/storage-mixin/downloads","issues_url":"https://api.github.com/repos/mongodb-js/storage-mixin/issues{/number}","pulls_url":"https://api.github.com/repos/mongodb-js/storage-mixin/pulls{/number}","milestones_url":"https://api.github.com/repos/mongodb-js/storage-mixin/milestones{/number}","notifications_url":"https://api.github.com/repos/mongodb-js/storage-mixin/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mongodb-js/storage-mixin/labels{/name}","releases_url":"https://api.github.com/repos/mongodb-js/storage-mixin/releases{/id}","created_at":"2015-11-28T23:51:28Z","updated_at":"2015-11-28T23:54:01Z","pushed_at":"2015-12-03T09:40:04Z","git_url":"git://github.com/mongodb-js/storage-mixin.git","ssh_url":"git@github.com:mongodb-js/storage-mixin.git","clone_url":"https://github.com/mongodb-js/storage-mixin.git","svn_url":"https://github.com/mongodb-js/storage-mixin","homepage":null,"size":98,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/mongodb-js/storage-mixin/pulls/8"},"html":{"href":"https://github.com/mongodb-js/storage-mixin/pull/8"},"issue":{"href":"https://api.github.com/repos/mongodb-js/storage-mixin/issues/8"},"comments":{"href":"https://api.github.com/repos/mongodb-js/storage-mixin/issues/8/comments"},"review_comments":{"href":"https://api.github.com/repos/mongodb-js/storage-mixin/pulls/8/comments"},"review_comment":{"href":"https://api.github.com/repos/mongodb-js/storage-mixin/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/mongodb-js/storage-mixin/pulls/8/commits"},"statuses":{"href":"https://api.github.com/repos/mongodb-js/storage-mixin/statuses/01d1db46c380bfb8e617072d5dff5d8e0caa4db0"}},"merged":true,"mergeable":null,"mergeable_state":"unknown","merged_by":{"login":"rueckstiess","id":99221,"avatar_url":"https://avatars.githubusercontent.com/u/99221?v=3","gravatar_id":"","url":"https://api.github.com/users/rueckstiess","html_url":"https://github.com/rueckstiess","followers_url":"https://api.github.com/users/rueckstiess/followers","following_url":"https://api.github.com/users/rueckstiess/following{/other_user}","gists_url":"https://api.github.com/users/rueckstiess/gists{/gist_id}","starred_url":"https://api.github.com/users/rueckstiess/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rueckstiess/subscriptions","organizations_url":"https://api.github.com/users/rueckstiess/orgs","repos_url":"https://api.github.com/users/rueckstiess/repos","events_url":"https://api.github.com/users/rueckstiess/events{/privacy}","received_events_url":"https://api.github.com/users/rueckstiess/received_events","type":"User","site_admin":false},"comments":0,"review_comments":0,"commits":3,"additions":81,"deletions":6,"changed_files":6}}