{"action":"created","comment":{"url":"https://api.github.com/repos/GoogleChrome/big-rig/pulls/comments/47496915","id":47496915,"diff_hunk":"@@ -0,0 +1,261 @@\n+/**\n+ * Copyright 2015 Google Inc. All rights reserved.\n+ *\n+ * Licensed under the Apache License, Version 2.0 (the \"License\");\n+ * you may not use this file except in compliance with the License.\n+ * You may obtain a copy of the License at\n+ *\n+ *     http://www.apache.org/licenses/LICENSE-2.0\n+ *\n+ * Unless required by applicable law or agreed to in writing, software\n+ * distributed under the License is distributed on an \"AS IS\" BASIS,\n+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n+ * See the License for the specific language governing permissions and\n+ * limitations under the License.\n+ */\n+\n+'use strict';\n+\n+let ModelFactory = require('../helpers/model-factory');\n+let Connection = require('./connection');\n+\n+class DataStore {\n+\n+  constructor () {\n+    this.storeName_ = null;\n+  }\n+\n+  configure (opts) {\n+    if (typeof opts === 'undefined') {\n+      throw new Error('DataStore configuration not provided.');\n+    }\n+\n+    this.storeName = opts.store || null;\n+    ModelFactory.modelData = opts.models || null;\n+  }\n+\n+  get storeName () {\n+    return this.storeName_;\n+  }\n+\n+  set storeName (storeName) {\n+    this.storeName_ = storeName;\n+  }\n+\n+  get models () {\n+    return ModelFactory.modelData;\n+  }\n+\n+  set models (modelData) {\n+    ModelFactory.modelData = modelData;\n+  }\n+\n+  _ensureValidPopulations (populations) {\n+    // Assume missing.\n+    if (typeof populations === 'undefined' || populations === null) {\n+      return [];\n+    }\n+\n+    // Assume string.\n+    if (typeof populations === 'string') {\n+      return [populations];\n+    }\n+\n+    // Assume object.\n+    if (typeof populations.length === 'undefined') {\n+      return [populations];\n+    }\n+\n+    // Assume array.\n+    return populations;\n+  }\n+\n+  action_ (type, cb) {\n+    if (this.storeName === null) {\n+      return Promise.reject(new Error('Database name must be set.'));\n+    }\n+\n+    let connection;\n+\n+    return Connection\n+\n+        // Get a connection.\n+        .getFromPool(this.storeName)\n+\n+        // Store it so it can be released later.\n+        .then(conn => {\n+          connection = conn;\n+        })\n+\n+        // Call the callback.\n+        .then(() => {\n+          let model = ModelFactory.get(type);\n+\n+          if (model === null) {\n+            return Promise.reject(new Error('No model found for ' + type));\n+          }\n+\n+          return cb(model);\n+        })\n+\n+        // Propagate the result\n+        .then(result => {\n+          Connection.returnToPool(connection);\n+          return result;\n+        }).catch(err => {\n+          Connection.returnToPool(connection);\n+          throw err;\n+        });\n+  }\n+\n+  put (type, data, id) {","path":"src/models/datastore.js","position":111,"original_position":111,"commit_id":"491b51b95ec58cda91bd97fbb1b040463a3cf300","original_commit_id":"491b51b95ec58cda91bd97fbb1b040463a3cf300","user":{"login":"gauntface","id":139760,"avatar_url":"https://avatars.githubusercontent.com/u/139760?v=3","gravatar_id":"","url":"https://api.github.com/users/gauntface","html_url":"https://github.com/gauntface","followers_url":"https://api.github.com/users/gauntface/followers","following_url":"https://api.github.com/users/gauntface/following{/other_user}","gists_url":"https://api.github.com/users/gauntface/gists{/gist_id}","starred_url":"https://api.github.com/users/gauntface/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gauntface/subscriptions","organizations_url":"https://api.github.com/users/gauntface/orgs","repos_url":"https://api.github.com/users/gauntface/repos","events_url":"https://api.github.com/users/gauntface/events{/privacy}","received_events_url":"https://api.github.com/users/gauntface/received_events","type":"User","site_admin":false},"body":"rename to modelType","created_at":"2015-12-14T13:30:47Z","updated_at":"2015-12-14T13:30:47Z","html_url":"https://github.com/GoogleChrome/big-rig/pull/27#discussion_r47496915","pull_request_url":"https://api.github.com/repos/GoogleChrome/big-rig/pulls/27","_links":{"self":{"href":"https://api.github.com/repos/GoogleChrome/big-rig/pulls/comments/47496915"},"html":{"href":"https://github.com/GoogleChrome/big-rig/pull/27#discussion_r47496915"},"pull_request":{"href":"https://api.github.com/repos/GoogleChrome/big-rig/pulls/27"}}},"pull_request":{"url":"https://api.github.com/repos/GoogleChrome/big-rig/pulls/27","id":53553174,"html_url":"https://github.com/GoogleChrome/big-rig/pull/27","diff_url":"https://github.com/GoogleChrome/big-rig/pull/27.diff","patch_url":"https://github.com/GoogleChrome/big-rig/pull/27.patch","issue_url":"https://api.github.com/repos/GoogleChrome/big-rig/issues/27","number":27,"state":"open","locked":false,"title":"Switch MySQL for MongoDB","user":{"login":"paullewis","id":617438,"avatar_url":"https://avatars.githubusercontent.com/u/617438?v=3","gravatar_id":"","url":"https://api.github.com/users/paullewis","html_url":"https://github.com/paullewis","followers_url":"https://api.github.com/users/paullewis/followers","following_url":"https://api.github.com/users/paullewis/following{/other_user}","gists_url":"https://api.github.com/users/paullewis/gists{/gist_id}","starred_url":"https://api.github.com/users/paullewis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/paullewis/subscriptions","organizations_url":"https://api.github.com/users/paullewis/orgs","repos_url":"https://api.github.com/users/paullewis/repos","events_url":"https://api.github.com/users/paullewis/events{/privacy}","received_events_url":"https://api.github.com/users/paullewis/received_events","type":"User","site_admin":false},"body":"R: @gauntface ","created_at":"2015-12-14T11:30:56Z","updated_at":"2015-12-14T13:30:47Z","closed_at":null,"merged_at":null,"merge_commit_sha":"e54a749bb9d873343025beefccebe92222d9151a","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/GoogleChrome/big-rig/pulls/27/commits","review_comments_url":"https://api.github.com/repos/GoogleChrome/big-rig/pulls/27/comments","review_comment_url":"https://api.github.com/repos/GoogleChrome/big-rig/pulls/comments{/number}","comments_url":"https://api.github.com/repos/GoogleChrome/big-rig/issues/27/comments","statuses_url":"https://api.github.com/repos/GoogleChrome/big-rig/statuses/491b51b95ec58cda91bd97fbb1b040463a3cf300","head":{"label":"GoogleChrome:node-mongodb","ref":"node-mongodb","sha":"491b51b95ec58cda91bd97fbb1b040463a3cf300","user":{"login":"GoogleChrome","id":1778935,"avatar_url":"https://avatars.githubusercontent.com/u/1778935?v=3","gravatar_id":"","url":"https://api.github.com/users/GoogleChrome","html_url":"https://github.com/GoogleChrome","followers_url":"https://api.github.com/users/GoogleChrome/followers","following_url":"https://api.github.com/users/GoogleChrome/following{/other_user}","gists_url":"https://api.github.com/users/GoogleChrome/gists{/gist_id}","starred_url":"https://api.github.com/users/GoogleChrome/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GoogleChrome/subscriptions","organizations_url":"https://api.github.com/users/GoogleChrome/orgs","repos_url":"https://api.github.com/users/GoogleChrome/repos","events_url":"https://api.github.com/users/GoogleChrome/events{/privacy}","received_events_url":"https://api.github.com/users/GoogleChrome/received_events","type":"Organization","site_admin":false},"repo":{"id":45275674,"name":"big-rig","full_name":"GoogleChrome/big-rig","owner":{"login":"GoogleChrome","id":1778935,"avatar_url":"https://avatars.githubusercontent.com/u/1778935?v=3","gravatar_id":"","url":"https://api.github.com/users/GoogleChrome","html_url":"https://github.com/GoogleChrome","followers_url":"https://api.github.com/users/GoogleChrome/followers","following_url":"https://api.github.com/users/GoogleChrome/following{/other_user}","gists_url":"https://api.github.com/users/GoogleChrome/gists{/gist_id}","starred_url":"https://api.github.com/users/GoogleChrome/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GoogleChrome/subscriptions","organizations_url":"https://api.github.com/users/GoogleChrome/orgs","repos_url":"https://api.github.com/users/GoogleChrome/repos","events_url":"https://api.github.com/users/GoogleChrome/events{/privacy}","received_events_url":"https://api.github.com/users/GoogleChrome/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/GoogleChrome/big-rig","description":"A proof-of-concept Performance Dashboard, CLI and Node module","fork":false,"url":"https://api.github.com/repos/GoogleChrome/big-rig","forks_url":"https://api.github.com/repos/GoogleChrome/big-rig/forks","keys_url":"https://api.github.com/repos/GoogleChrome/big-rig/keys{/key_id}","collaborators_url":"https://api.github.com/repos/GoogleChrome/big-rig/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/GoogleChrome/big-rig/teams","hooks_url":"https://api.github.com/repos/GoogleChrome/big-rig/hooks","issue_events_url":"https://api.github.com/repos/GoogleChrome/big-rig/issues/events{/number}","events_url":"https://api.github.com/repos/GoogleChrome/big-rig/events","assignees_url":"https://api.github.com/repos/GoogleChrome/big-rig/assignees{/user}","branches_url":"https://api.github.com/repos/GoogleChrome/big-rig/branches{/branch}","tags_url":"https://api.github.com/repos/GoogleChrome/big-rig/tags","blobs_url":"https://api.github.com/repos/GoogleChrome/big-rig/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/GoogleChrome/big-rig/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/GoogleChrome/big-rig/git/refs{/sha}","trees_url":"https://api.github.com/repos/GoogleChrome/big-rig/git/trees{/sha}","statuses_url":"https://api.github.com/repos/GoogleChrome/big-rig/statuses/{sha}","languages_url":"https://api.github.com/repos/GoogleChrome/big-rig/languages","stargazers_url":"https://api.github.com/repos/GoogleChrome/big-rig/stargazers","contributors_url":"https://api.github.com/repos/GoogleChrome/big-rig/contributors","subscribers_url":"https://api.github.com/repos/GoogleChrome/big-rig/subscribers","subscription_url":"https://api.github.com/repos/GoogleChrome/big-rig/subscription","commits_url":"https://api.github.com/repos/GoogleChrome/big-rig/commits{/sha}","git_commits_url":"https://api.github.com/repos/GoogleChrome/big-rig/git/commits{/sha}","comments_url":"https://api.github.com/repos/GoogleChrome/big-rig/comments{/number}","issue_comment_url":"https://api.github.com/repos/GoogleChrome/big-rig/issues/comments{/number}","contents_url":"https://api.github.com/repos/GoogleChrome/big-rig/contents/{+path}","compare_url":"https://api.github.com/repos/GoogleChrome/big-rig/compare/{base}...{head}","merges_url":"https://api.github.com/repos/GoogleChrome/big-rig/merges","archive_url":"https://api.github.com/repos/GoogleChrome/big-rig/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/GoogleChrome/big-rig/downloads","issues_url":"https://api.github.com/repos/GoogleChrome/big-rig/issues{/number}","pulls_url":"https://api.github.com/repos/GoogleChrome/big-rig/pulls{/number}","milestones_url":"https://api.github.com/repos/GoogleChrome/big-rig/milestones{/number}","notifications_url":"https://api.github.com/repos/GoogleChrome/big-rig/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/GoogleChrome/big-rig/labels{/name}","releases_url":"https://api.github.com/repos/GoogleChrome/big-rig/releases{/id}","created_at":"2015-10-30T20:45:22Z","updated_at":"2015-12-14T08:05:22Z","pushed_at":"2015-12-14T11:37:29Z","git_url":"git://github.com/GoogleChrome/big-rig.git","ssh_url":"git@github.com:GoogleChrome/big-rig.git","clone_url":"https://github.com/GoogleChrome/big-rig.git","svn_url":"https://github.com/GoogleChrome/big-rig","homepage":"","size":4091,"stargazers_count":507,"watchers_count":507,"language":"CSS","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":23,"mirror_url":null,"open_issues_count":9,"forks":23,"open_issues":9,"watchers":507,"default_branch":"master"}},"base":{"label":"GoogleChrome:node","ref":"node","sha":"f9c9deb1ec1a4c29c5b4b2e743885e7c3b1ba665","user":{"login":"GoogleChrome","id":1778935,"avatar_url":"https://avatars.githubusercontent.com/u/1778935?v=3","gravatar_id":"","url":"https://api.github.com/users/GoogleChrome","html_url":"https://github.com/GoogleChrome","followers_url":"https://api.github.com/users/GoogleChrome/followers","following_url":"https://api.github.com/users/GoogleChrome/following{/other_user}","gists_url":"https://api.github.com/users/GoogleChrome/gists{/gist_id}","starred_url":"https://api.github.com/users/GoogleChrome/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GoogleChrome/subscriptions","organizations_url":"https://api.github.com/users/GoogleChrome/orgs","repos_url":"https://api.github.com/users/GoogleChrome/repos","events_url":"https://api.github.com/users/GoogleChrome/events{/privacy}","received_events_url":"https://api.github.com/users/GoogleChrome/received_events","type":"Organization","site_admin":false},"repo":{"id":45275674,"name":"big-rig","full_name":"GoogleChrome/big-rig","owner":{"login":"GoogleChrome","id":1778935,"avatar_url":"https://avatars.githubusercontent.com/u/1778935?v=3","gravatar_id":"","url":"https://api.github.com/users/GoogleChrome","html_url":"https://github.com/GoogleChrome","followers_url":"https://api.github.com/users/GoogleChrome/followers","following_url":"https://api.github.com/users/GoogleChrome/following{/other_user}","gists_url":"https://api.github.com/users/GoogleChrome/gists{/gist_id}","starred_url":"https://api.github.com/users/GoogleChrome/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GoogleChrome/subscriptions","organizations_url":"https://api.github.com/users/GoogleChrome/orgs","repos_url":"https://api.github.com/users/GoogleChrome/repos","events_url":"https://api.github.com/users/GoogleChrome/events{/privacy}","received_events_url":"https://api.github.com/users/GoogleChrome/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/GoogleChrome/big-rig","description":"A proof-of-concept Performance Dashboard, CLI and Node module","fork":false,"url":"https://api.github.com/repos/GoogleChrome/big-rig","forks_url":"https://api.github.com/repos/GoogleChrome/big-rig/forks","keys_url":"https://api.github.com/repos/GoogleChrome/big-rig/keys{/key_id}","collaborators_url":"https://api.github.com/repos/GoogleChrome/big-rig/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/GoogleChrome/big-rig/teams","hooks_url":"https://api.github.com/repos/GoogleChrome/big-rig/hooks","issue_events_url":"https://api.github.com/repos/GoogleChrome/big-rig/issues/events{/number}","events_url":"https://api.github.com/repos/GoogleChrome/big-rig/events","assignees_url":"https://api.github.com/repos/GoogleChrome/big-rig/assignees{/user}","branches_url":"https://api.github.com/repos/GoogleChrome/big-rig/branches{/branch}","tags_url":"https://api.github.com/repos/GoogleChrome/big-rig/tags","blobs_url":"https://api.github.com/repos/GoogleChrome/big-rig/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/GoogleChrome/big-rig/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/GoogleChrome/big-rig/git/refs{/sha}","trees_url":"https://api.github.com/repos/GoogleChrome/big-rig/git/trees{/sha}","statuses_url":"https://api.github.com/repos/GoogleChrome/big-rig/statuses/{sha}","languages_url":"https://api.github.com/repos/GoogleChrome/big-rig/languages","stargazers_url":"https://api.github.com/repos/GoogleChrome/big-rig/stargazers","contributors_url":"https://api.github.com/repos/GoogleChrome/big-rig/contributors","subscribers_url":"https://api.github.com/repos/GoogleChrome/big-rig/subscribers","subscription_url":"https://api.github.com/repos/GoogleChrome/big-rig/subscription","commits_url":"https://api.github.com/repos/GoogleChrome/big-rig/commits{/sha}","git_commits_url":"https://api.github.com/repos/GoogleChrome/big-rig/git/commits{/sha}","comments_url":"https://api.github.com/repos/GoogleChrome/big-rig/comments{/number}","issue_comment_url":"https://api.github.com/repos/GoogleChrome/big-rig/issues/comments{/number}","contents_url":"https://api.github.com/repos/GoogleChrome/big-rig/contents/{+path}","compare_url":"https://api.github.com/repos/GoogleChrome/big-rig/compare/{base}...{head}","merges_url":"https://api.github.com/repos/GoogleChrome/big-rig/merges","archive_url":"https://api.github.com/repos/GoogleChrome/big-rig/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/GoogleChrome/big-rig/downloads","issues_url":"https://api.github.com/repos/GoogleChrome/big-rig/issues{/number}","pulls_url":"https://api.github.com/repos/GoogleChrome/big-rig/pulls{/number}","milestones_url":"https://api.github.com/repos/GoogleChrome/big-rig/milestones{/number}","notifications_url":"https://api.github.com/repos/GoogleChrome/big-rig/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/GoogleChrome/big-rig/labels{/name}","releases_url":"https://api.github.com/repos/GoogleChrome/big-rig/releases{/id}","created_at":"2015-10-30T20:45:22Z","updated_at":"2015-12-14T08:05:22Z","pushed_at":"2015-12-14T11:37:29Z","git_url":"git://github.com/GoogleChrome/big-rig.git","ssh_url":"git@github.com:GoogleChrome/big-rig.git","clone_url":"https://github.com/GoogleChrome/big-rig.git","svn_url":"https://github.com/GoogleChrome/big-rig","homepage":"","size":4091,"stargazers_count":507,"watchers_count":507,"language":"CSS","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":23,"mirror_url":null,"open_issues_count":9,"forks":23,"open_issues":9,"watchers":507,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/GoogleChrome/big-rig/pulls/27"},"html":{"href":"https://github.com/GoogleChrome/big-rig/pull/27"},"issue":{"href":"https://api.github.com/repos/GoogleChrome/big-rig/issues/27"},"comments":{"href":"https://api.github.com/repos/GoogleChrome/big-rig/issues/27/comments"},"review_comments":{"href":"https://api.github.com/repos/GoogleChrome/big-rig/pulls/27/comments"},"review_comment":{"href":"https://api.github.com/repos/GoogleChrome/big-rig/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/GoogleChrome/big-rig/pulls/27/commits"},"statuses":{"href":"https://api.github.com/repos/GoogleChrome/big-rig/statuses/491b51b95ec58cda91bd97fbb1b040463a3cf300"}}}}