{"action":"created","comment":{"url":"https://api.github.com/repos/hoodiehq/pouchdb-hoodie-store/pulls/comments/39859333","id":39859333,"diff_hunk":"@@ -0,0 +1,156 @@\n+var merge = require('lodash.merge')\n+var test = require('tape')\n+\n+var Store = require('../../')\n+var options = process.browser ? {\n+  adapter: 'memory'\n+} : {\n+  db: require('memdown')\n+}\n+\n+test('scoped method', function (t) {\n+  t.plan(1)\n+\n+  var store = new Store('test-db-scoped', merge({remote: 'test-db-scoped'}, options))\n+\n+  t.is(typeof store.scoped, 'function', 'has \"scoped\" method')\n+})\n+\n+test('store.scoped(\"test\") with methods', function (t) {\n+  t.plan(12)\n+\n+  var store = new Store('test-db-scoped-store', merge({remote: 'test-db-scoped-store'}, options))\n+  var testStore = store.scoped('test')\n+\n+  t.is(typeof testStore.add, 'function', 'has \"add\" method')\n+  t.is(typeof testStore.find, 'function', 'has \"find\" method')\n+  t.is(typeof testStore.findOrAdd, 'function', 'has \"findOrAdd\" method')\n+  t.is(typeof testStore.findAll, 'function', 'has \"findAll\" method')\n+  t.is(typeof testStore.update, 'function', 'has \"update\" method')\n+  t.is(typeof testStore.updateOrAdd, 'function', 'has \"updateOrAdd\" method')\n+  t.is(typeof testStore.updateAll, 'function', 'has \"updateAll\" method')\n+  t.is(typeof testStore.remove, 'function', 'has \"remove\" method')\n+  t.is(typeof testStore.removeAll, 'function', 'has \"removeAll\" method')\n+  t.is(typeof testStore.on, 'function', 'has \"on\" method')\n+  t.is(typeof testStore.one, 'function', 'has \"one\" method')\n+  t.is(typeof testStore.off, 'function', 'has \"off\" method')\n+})\n+\n+test('scoped Store .on(\"change\") with adding one', function (t) {\n+  t.plan(4)\n+\n+  var store = new Store('test-db-scoped-add', merge({remote: 'test-db-scoped-add'}, options))\n+  var testStore = store.scoped('test')\n+  var changeEvents = []\n+\n+  testStore.on('change', addEventToArray.bind(null, changeEvents))\n+  store.on('change', addEventToArray.bind(null, changeEvents))\n+\n+  testStore.add({\n+    foo: 'bar'\n+  })\n+\n+  .then(function () {\n+    t.is(changeEvents.length, 1, 'triggers 1 change event')\n+    t.is(changeEvents[0].eventName, 'add', 'passes the event name')\n+    t.is(changeEvents[0].object.foo, 'bar', 'event passes object')\n+    t.is(changeEvents[0].object.type, 'test', 'event passes object with scoped type')\n+  })\n+})","path":"tests/specs/scoped.js","position":59,"original_position":59,"commit_id":"8b2072bdd9f0d197089b7324d409708244bdd60b","original_commit_id":"8b2072bdd9f0d197089b7324d409708244bdd60b","user":{"login":"HipsterBrown","id":3051193,"avatar_url":"https://avatars.githubusercontent.com/u/3051193?v=3","gravatar_id":"","url":"https://api.github.com/users/HipsterBrown","html_url":"https://github.com/HipsterBrown","followers_url":"https://api.github.com/users/HipsterBrown/followers","following_url":"https://api.github.com/users/HipsterBrown/following{/other_user}","gists_url":"https://api.github.com/users/HipsterBrown/gists{/gist_id}","starred_url":"https://api.github.com/users/HipsterBrown/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/HipsterBrown/subscriptions","organizations_url":"https://api.github.com/users/HipsterBrown/orgs","repos_url":"https://api.github.com/users/HipsterBrown/repos","events_url":"https://api.github.com/users/HipsterBrown/events{/privacy}","received_events_url":"https://api.github.com/users/HipsterBrown/received_events","type":"User","site_admin":false},"body":"Ah ok, I thought the event was completely scoped to that new `store`. That makes this a little easier. :smile: ","created_at":"2015-09-18T14:21:26Z","updated_at":"2015-09-18T14:21:26Z","html_url":"https://github.com/hoodiehq/pouchdb-hoodie-store/pull/43#discussion_r39859333","pull_request_url":"https://api.github.com/repos/hoodiehq/pouchdb-hoodie-store/pulls/43","_links":{"self":{"href":"https://api.github.com/repos/hoodiehq/pouchdb-hoodie-store/pulls/comments/39859333"},"html":{"href":"https://github.com/hoodiehq/pouchdb-hoodie-store/pull/43#discussion_r39859333"},"pull_request":{"href":"https://api.github.com/repos/hoodiehq/pouchdb-hoodie-store/pulls/43"}}},"pull_request":{"url":"https://api.github.com/repos/hoodiehq/pouchdb-hoodie-store/pulls/43","id":45345459,"html_url":"https://github.com/hoodiehq/pouchdb-hoodie-store/pull/43","diff_url":"https://github.com/hoodiehq/pouchdb-hoodie-store/pull/43.diff","patch_url":"https://github.com/hoodiehq/pouchdb-hoodie-store/pull/43.patch","issue_url":"https://api.github.com/repos/hoodiehq/pouchdb-hoodie-store/issues/43","number":43,"state":"open","locked":false,"title":"Scoped store","user":{"login":"HipsterBrown","id":3051193,"avatar_url":"https://avatars.githubusercontent.com/u/3051193?v=3","gravatar_id":"","url":"https://api.github.com/users/HipsterBrown","html_url":"https://github.com/HipsterBrown","followers_url":"https://api.github.com/users/HipsterBrown/followers","following_url":"https://api.github.com/users/HipsterBrown/following{/other_user}","gists_url":"https://api.github.com/users/HipsterBrown/gists{/gist_id}","starred_url":"https://api.github.com/users/HipsterBrown/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/HipsterBrown/subscriptions","organizations_url":"https://api.github.com/users/HipsterBrown/orgs","repos_url":"https://api.github.com/users/HipsterBrown/repos","events_url":"https://api.github.com/users/HipsterBrown/events{/privacy}","received_events_url":"https://api.github.com/users/HipsterBrown/received_events","type":"User","site_admin":false},"body":"This is a basic draft of `.scoped`. Any constructive feedback would be wunderbar. I still need to write tests for changing the `type` of an item in a scoped store but I went for the basics first. \r\n\r\nFixes #39 ","created_at":"2015-09-17T21:39:44Z","updated_at":"2015-09-18T14:21:26Z","closed_at":null,"merged_at":null,"merge_commit_sha":"2ce6517fe24af4930b0657af9fcaff3d26b876fb","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/hoodiehq/pouchdb-hoodie-store/pulls/43/commits","review_comments_url":"https://api.github.com/repos/hoodiehq/pouchdb-hoodie-store/pulls/43/comments","review_comment_url":"https://api.github.com/repos/hoodiehq/pouchdb-hoodie-store/pulls/comments{/number}","comments_url":"https://api.github.com/repos/hoodiehq/pouchdb-hoodie-store/issues/43/comments","statuses_url":"https://api.github.com/repos/hoodiehq/pouchdb-hoodie-store/statuses/8b2072bdd9f0d197089b7324d409708244bdd60b","head":{"label":"hoodiehq:scoped-store","ref":"scoped-store","sha":"8b2072bdd9f0d197089b7324d409708244bdd60b","user":{"login":"hoodiehq","id":1888826,"avatar_url":"https://avatars.githubusercontent.com/u/1888826?v=3","gravatar_id":"","url":"https://api.github.com/users/hoodiehq","html_url":"https://github.com/hoodiehq","followers_url":"https://api.github.com/users/hoodiehq/followers","following_url":"https://api.github.com/users/hoodiehq/following{/other_user}","gists_url":"https://api.github.com/users/hoodiehq/gists{/gist_id}","starred_url":"https://api.github.com/users/hoodiehq/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hoodiehq/subscriptions","organizations_url":"https://api.github.com/users/hoodiehq/orgs","repos_url":"https://api.github.com/users/hoodiehq/repos","events_url":"https://api.github.com/users/hoodiehq/events{/privacy}","received_events_url":"https://api.github.com/users/hoodiehq/received_events","type":"Organization","site_admin":false},"repo":{"id":36420691,"name":"pouchdb-hoodie-store","full_name":"hoodiehq/pouchdb-hoodie-store","owner":{"login":"hoodiehq","id":1888826,"avatar_url":"https://avatars.githubusercontent.com/u/1888826?v=3","gravatar_id":"","url":"https://api.github.com/users/hoodiehq","html_url":"https://github.com/hoodiehq","followers_url":"https://api.github.com/users/hoodiehq/followers","following_url":"https://api.github.com/users/hoodiehq/following{/other_user}","gists_url":"https://api.github.com/users/hoodiehq/gists{/gist_id}","starred_url":"https://api.github.com/users/hoodiehq/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hoodiehq/subscriptions","organizations_url":"https://api.github.com/users/hoodiehq/orgs","repos_url":"https://api.github.com/users/hoodiehq/repos","events_url":"https://api.github.com/users/hoodiehq/events{/privacy}","received_events_url":"https://api.github.com/users/hoodiehq/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/hoodiehq/pouchdb-hoodie-store","description":"Hoodie-like Store & Sync API on top of PouchDB","fork":false,"url":"https://api.github.com/repos/hoodiehq/pouchdb-hoodie-store","forks_url":"https://api.github.com/repos/hoodiehq/pouchdb-hoodie-store/forks","keys_url":"https://api.github.com/repos/hoodiehq/pouchdb-hoodie-store/keys{/key_id}","collaborators_url":"https://api.github.com/repos/hoodiehq/pouchdb-hoodie-store/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/hoodiehq/pouchdb-hoodie-store/teams","hooks_url":"https://api.github.com/repos/hoodiehq/pouchdb-hoodie-store/hooks","issue_events_url":"https://api.github.com/repos/hoodiehq/pouchdb-hoodie-store/issues/events{/number}","events_url":"https://api.github.com/repos/hoodiehq/pouchdb-hoodie-store/events","assignees_url":"https://api.github.com/repos/hoodiehq/pouchdb-hoodie-store/assignees{/user}","branches_url":"https://api.github.com/repos/hoodiehq/pouchdb-hoodie-store/branches{/branch}","tags_url":"https://api.github.com/repos/hoodiehq/pouchdb-hoodie-store/tags","blobs_url":"https://api.github.com/repos/hoodiehq/pouchdb-hoodie-store/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/hoodiehq/pouchdb-hoodie-store/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/hoodiehq/pouchdb-hoodie-store/git/refs{/sha}","trees_url":"https://api.github.com/repos/hoodiehq/pouchdb-hoodie-store/git/trees{/sha}","statuses_url":"https://api.github.com/repos/hoodiehq/pouchdb-hoodie-store/statuses/{sha}","languages_url":"https://api.github.com/repos/hoodiehq/pouchdb-hoodie-store/languages","stargazers_url":"https://api.github.com/repos/hoodiehq/pouchdb-hoodie-store/stargazers","contributors_url":"https://api.github.com/repos/hoodiehq/pouchdb-hoodie-store/contributors","subscribers_url":"https://api.github.com/repos/hoodiehq/pouchdb-hoodie-store/subscribers","subscription_url":"https://api.github.com/repos/hoodiehq/pouchdb-hoodie-store/subscription","commits_url":"https://api.github.com/repos/hoodiehq/pouchdb-hoodie-store/commits{/sha}","git_commits_url":"https://api.github.com/repos/hoodiehq/pouchdb-hoodie-store/git/commits{/sha}","comments_url":"https://api.github.com/repos/hoodiehq/pouchdb-hoodie-store/comments{/number}","issue_comment_url":"https://api.github.com/repos/hoodiehq/pouchdb-hoodie-store/issues/comments{/number}","contents_url":"https://api.github.com/repos/hoodiehq/pouchdb-hoodie-store/contents/{+path}","compare_url":"https://api.github.com/repos/hoodiehq/pouchdb-hoodie-store/compare/{base}...{head}","merges_url":"https://api.github.com/repos/hoodiehq/pouchdb-hoodie-store/merges","archive_url":"https://api.github.com/repos/hoodiehq/pouchdb-hoodie-store/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/hoodiehq/pouchdb-hoodie-store/downloads","issues_url":"https://api.github.com/repos/hoodiehq/pouchdb-hoodie-store/issues{/number}","pulls_url":"https://api.github.com/repos/hoodiehq/pouchdb-hoodie-store/pulls{/number}","milestones_url":"https://api.github.com/repos/hoodiehq/pouchdb-hoodie-store/milestones{/number}","notifications_url":"https://api.github.com/repos/hoodiehq/pouchdb-hoodie-store/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/hoodiehq/pouchdb-hoodie-store/labels{/name}","releases_url":"https://api.github.com/repos/hoodiehq/pouchdb-hoodie-store/releases{/id}","created_at":"2015-05-28T07:01:51Z","updated_at":"2015-09-14T01:24:44Z","pushed_at":"2015-09-17T23:16:53Z","git_url":"git://github.com/hoodiehq/pouchdb-hoodie-store.git","ssh_url":"git@github.com:hoodiehq/pouchdb-hoodie-store.git","clone_url":"https://github.com/hoodiehq/pouchdb-hoodie-store.git","svn_url":"https://github.com/hoodiehq/pouchdb-hoodie-store","homepage":null,"size":336,"stargazers_count":3,"watchers_count":3,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":3,"mirror_url":null,"open_issues_count":3,"forks":3,"open_issues":3,"watchers":3,"default_branch":"master"}},"base":{"label":"hoodiehq:master","ref":"master","sha":"f84b81ac47cef07ea34376676095aadaadce6bec","user":{"login":"hoodiehq","id":1888826,"avatar_url":"https://avatars.githubusercontent.com/u/1888826?v=3","gravatar_id":"","url":"https://api.github.com/users/hoodiehq","html_url":"https://github.com/hoodiehq","followers_url":"https://api.github.com/users/hoodiehq/followers","following_url":"https://api.github.com/users/hoodiehq/following{/other_user}","gists_url":"https://api.github.com/users/hoodiehq/gists{/gist_id}","starred_url":"https://api.github.com/users/hoodiehq/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hoodiehq/subscriptions","organizations_url":"https://api.github.com/users/hoodiehq/orgs","repos_url":"https://api.github.com/users/hoodiehq/repos","events_url":"https://api.github.com/users/hoodiehq/events{/privacy}","received_events_url":"https://api.github.com/users/hoodiehq/received_events","type":"Organization","site_admin":false},"repo":{"id":36420691,"name":"pouchdb-hoodie-store","full_name":"hoodiehq/pouchdb-hoodie-store","owner":{"login":"hoodiehq","id":1888826,"avatar_url":"https://avatars.githubusercontent.com/u/1888826?v=3","gravatar_id":"","url":"https://api.github.com/users/hoodiehq","html_url":"https://github.com/hoodiehq","followers_url":"https://api.github.com/users/hoodiehq/followers","following_url":"https://api.github.com/users/hoodiehq/following{/other_user}","gists_url":"https://api.github.com/users/hoodiehq/gists{/gist_id}","starred_url":"https://api.github.com/users/hoodiehq/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hoodiehq/subscriptions","organizations_url":"https://api.github.com/users/hoodiehq/orgs","repos_url":"https://api.github.com/users/hoodiehq/repos","events_url":"https://api.github.com/users/hoodiehq/events{/privacy}","received_events_url":"https://api.github.com/users/hoodiehq/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/hoodiehq/pouchdb-hoodie-store","description":"Hoodie-like Store & Sync API on top of PouchDB","fork":false,"url":"https://api.github.com/repos/hoodiehq/pouchdb-hoodie-store","forks_url":"https://api.github.com/repos/hoodiehq/pouchdb-hoodie-store/forks","keys_url":"https://api.github.com/repos/hoodiehq/pouchdb-hoodie-store/keys{/key_id}","collaborators_url":"https://api.github.com/repos/hoodiehq/pouchdb-hoodie-store/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/hoodiehq/pouchdb-hoodie-store/teams","hooks_url":"https://api.github.com/repos/hoodiehq/pouchdb-hoodie-store/hooks","issue_events_url":"https://api.github.com/repos/hoodiehq/pouchdb-hoodie-store/issues/events{/number}","events_url":"https://api.github.com/repos/hoodiehq/pouchdb-hoodie-store/events","assignees_url":"https://api.github.com/repos/hoodiehq/pouchdb-hoodie-store/assignees{/user}","branches_url":"https://api.github.com/repos/hoodiehq/pouchdb-hoodie-store/branches{/branch}","tags_url":"https://api.github.com/repos/hoodiehq/pouchdb-hoodie-store/tags","blobs_url":"https://api.github.com/repos/hoodiehq/pouchdb-hoodie-store/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/hoodiehq/pouchdb-hoodie-store/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/hoodiehq/pouchdb-hoodie-store/git/refs{/sha}","trees_url":"https://api.github.com/repos/hoodiehq/pouchdb-hoodie-store/git/trees{/sha}","statuses_url":"https://api.github.com/repos/hoodiehq/pouchdb-hoodie-store/statuses/{sha}","languages_url":"https://api.github.com/repos/hoodiehq/pouchdb-hoodie-store/languages","stargazers_url":"https://api.github.com/repos/hoodiehq/pouchdb-hoodie-store/stargazers","contributors_url":"https://api.github.com/repos/hoodiehq/pouchdb-hoodie-store/contributors","subscribers_url":"https://api.github.com/repos/hoodiehq/pouchdb-hoodie-store/subscribers","subscription_url":"https://api.github.com/repos/hoodiehq/pouchdb-hoodie-store/subscription","commits_url":"https://api.github.com/repos/hoodiehq/pouchdb-hoodie-store/commits{/sha}","git_commits_url":"https://api.github.com/repos/hoodiehq/pouchdb-hoodie-store/git/commits{/sha}","comments_url":"https://api.github.com/repos/hoodiehq/pouchdb-hoodie-store/comments{/number}","issue_comment_url":"https://api.github.com/repos/hoodiehq/pouchdb-hoodie-store/issues/comments{/number}","contents_url":"https://api.github.com/repos/hoodiehq/pouchdb-hoodie-store/contents/{+path}","compare_url":"https://api.github.com/repos/hoodiehq/pouchdb-hoodie-store/compare/{base}...{head}","merges_url":"https://api.github.com/repos/hoodiehq/pouchdb-hoodie-store/merges","archive_url":"https://api.github.com/repos/hoodiehq/pouchdb-hoodie-store/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/hoodiehq/pouchdb-hoodie-store/downloads","issues_url":"https://api.github.com/repos/hoodiehq/pouchdb-hoodie-store/issues{/number}","pulls_url":"https://api.github.com/repos/hoodiehq/pouchdb-hoodie-store/pulls{/number}","milestones_url":"https://api.github.com/repos/hoodiehq/pouchdb-hoodie-store/milestones{/number}","notifications_url":"https://api.github.com/repos/hoodiehq/pouchdb-hoodie-store/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/hoodiehq/pouchdb-hoodie-store/labels{/name}","releases_url":"https://api.github.com/repos/hoodiehq/pouchdb-hoodie-store/releases{/id}","created_at":"2015-05-28T07:01:51Z","updated_at":"2015-09-14T01:24:44Z","pushed_at":"2015-09-17T23:16:53Z","git_url":"git://github.com/hoodiehq/pouchdb-hoodie-store.git","ssh_url":"git@github.com:hoodiehq/pouchdb-hoodie-store.git","clone_url":"https://github.com/hoodiehq/pouchdb-hoodie-store.git","svn_url":"https://github.com/hoodiehq/pouchdb-hoodie-store","homepage":null,"size":336,"stargazers_count":3,"watchers_count":3,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":3,"mirror_url":null,"open_issues_count":3,"forks":3,"open_issues":3,"watchers":3,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/hoodiehq/pouchdb-hoodie-store/pulls/43"},"html":{"href":"https://github.com/hoodiehq/pouchdb-hoodie-store/pull/43"},"issue":{"href":"https://api.github.com/repos/hoodiehq/pouchdb-hoodie-store/issues/43"},"comments":{"href":"https://api.github.com/repos/hoodiehq/pouchdb-hoodie-store/issues/43/comments"},"review_comments":{"href":"https://api.github.com/repos/hoodiehq/pouchdb-hoodie-store/pulls/43/comments"},"review_comment":{"href":"https://api.github.com/repos/hoodiehq/pouchdb-hoodie-store/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/hoodiehq/pouchdb-hoodie-store/pulls/43/commits"},"statuses":{"href":"https://api.github.com/repos/hoodiehq/pouchdb-hoodie-store/statuses/8b2072bdd9f0d197089b7324d409708244bdd60b"}}}}