{"action":"opened","number":297,"pull_request":{"url":"https://api.github.com/repos/robconery/massive-js/pulls/297","id":79526066,"html_url":"https://github.com/robconery/massive-js/pull/297","diff_url":"https://github.com/robconery/massive-js/pull/297.diff","patch_url":"https://github.com/robconery/massive-js/pull/297.patch","issue_url":"https://api.github.com/repos/robconery/massive-js/issues/297","number":297,"state":"open","locked":false,"title":"Refactor index.js","user":{"login":"benjie","id":129910,"avatar_url":"https://avatars.githubusercontent.com/u/129910?v=3","gravatar_id":"","url":"https://api.github.com/users/benjie","html_url":"https://github.com/benjie","followers_url":"https://api.github.com/users/benjie/followers","following_url":"https://api.github.com/users/benjie/following{/other_user}","gists_url":"https://api.github.com/users/benjie/gists{/gist_id}","starred_url":"https://api.github.com/users/benjie/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/benjie/subscriptions","organizations_url":"https://api.github.com/users/benjie/orgs","repos_url":"https://api.github.com/users/benjie/repos","events_url":"https://api.github.com/users/benjie/events{/privacy}","received_events_url":"https://api.github.com/users/benjie/received_events","type":"User","site_admin":false},"body":"This is the refactoring changes from #295 with an improvement (and test) to loading `db/query.sql` and `db/query/file.sql` both.\r\n\r\n- Factors out the global `self` variable in index.js which allows you to `massive.connect` to multiple databases without as many issues as before\r\n- Refactors `walkSqlFiles` to be asynchronous for consistency\r\n- Splits `connect` into two phases: the collection phase: `bootstrap` (which queries the database, filesystem, etc); and the initialisation phase: `initialize` (which takes the data from the collection phase and applies it to the local instance)\r\n- Fixes the missing error handler [here](https://github.com/robconery/massive-js/blob/75b9208acdcc41b59a27152b1520a06cdc1f92e4/index.js#L477-L478)\r\n- Uses `fs.stat` rather than extension/error to see if paths are files/directories\r\n- Fixes the issues of having both `db/query.sql` and `db/query/file.sql` - now deterministically loads both queries rather than the previous behaviour which would have one or the other win based on the filesystem order\r\n- **[BREAKING]** Prevents SQL files from overwriting existing methods\r\n  - Warns the user via either console.warn or a custom notifier if there's a clash\r\n  - No longer deletes built in functions if they share a name with a script source folder\r\n","created_at":"2016-08-01T07:41:09Z","updated_at":"2016-08-01T07:41:09Z","closed_at":null,"merged_at":null,"merge_commit_sha":"7d0bc095b79eeec3bc94d14d6325281e61fcfcf8","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/robconery/massive-js/pulls/297/commits","review_comments_url":"https://api.github.com/repos/robconery/massive-js/pulls/297/comments","review_comment_url":"https://api.github.com/repos/robconery/massive-js/pulls/comments{/number}","comments_url":"https://api.github.com/repos/robconery/massive-js/issues/297/comments","statuses_url":"https://api.github.com/repos/robconery/massive-js/statuses/b96587ca6da6c0f7d200e37e44ab7c905c8ab4a1","head":{"label":"benjie:refactor-index","ref":"refactor-index","sha":"b96587ca6da6c0f7d200e37e44ab7c905c8ab4a1","user":{"login":"benjie","id":129910,"avatar_url":"https://avatars.githubusercontent.com/u/129910?v=3","gravatar_id":"","url":"https://api.github.com/users/benjie","html_url":"https://github.com/benjie","followers_url":"https://api.github.com/users/benjie/followers","following_url":"https://api.github.com/users/benjie/following{/other_user}","gists_url":"https://api.github.com/users/benjie/gists{/gist_id}","starred_url":"https://api.github.com/users/benjie/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/benjie/subscriptions","organizations_url":"https://api.github.com/users/benjie/orgs","repos_url":"https://api.github.com/users/benjie/repos","events_url":"https://api.github.com/users/benjie/events{/privacy}","received_events_url":"https://api.github.com/users/benjie/received_events","type":"User","site_admin":false},"repo":{"id":64061422,"name":"massive-js","full_name":"benjie/massive-js","owner":{"login":"benjie","id":129910,"avatar_url":"https://avatars.githubusercontent.com/u/129910?v=3","gravatar_id":"","url":"https://api.github.com/users/benjie","html_url":"https://github.com/benjie","followers_url":"https://api.github.com/users/benjie/followers","following_url":"https://api.github.com/users/benjie/following{/other_user}","gists_url":"https://api.github.com/users/benjie/gists{/gist_id}","starred_url":"https://api.github.com/users/benjie/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/benjie/subscriptions","organizations_url":"https://api.github.com/users/benjie/orgs","repos_url":"https://api.github.com/users/benjie/repos","events_url":"https://api.github.com/users/benjie/events{/privacy}","received_events_url":"https://api.github.com/users/benjie/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/benjie/massive-js","description":"A simple relational data access tool for NodeJS. ","fork":true,"url":"https://api.github.com/repos/benjie/massive-js","forks_url":"https://api.github.com/repos/benjie/massive-js/forks","keys_url":"https://api.github.com/repos/benjie/massive-js/keys{/key_id}","collaborators_url":"https://api.github.com/repos/benjie/massive-js/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/benjie/massive-js/teams","hooks_url":"https://api.github.com/repos/benjie/massive-js/hooks","issue_events_url":"https://api.github.com/repos/benjie/massive-js/issues/events{/number}","events_url":"https://api.github.com/repos/benjie/massive-js/events","assignees_url":"https://api.github.com/repos/benjie/massive-js/assignees{/user}","branches_url":"https://api.github.com/repos/benjie/massive-js/branches{/branch}","tags_url":"https://api.github.com/repos/benjie/massive-js/tags","blobs_url":"https://api.github.com/repos/benjie/massive-js/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/benjie/massive-js/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/benjie/massive-js/git/refs{/sha}","trees_url":"https://api.github.com/repos/benjie/massive-js/git/trees{/sha}","statuses_url":"https://api.github.com/repos/benjie/massive-js/statuses/{sha}","languages_url":"https://api.github.com/repos/benjie/massive-js/languages","stargazers_url":"https://api.github.com/repos/benjie/massive-js/stargazers","contributors_url":"https://api.github.com/repos/benjie/massive-js/contributors","subscribers_url":"https://api.github.com/repos/benjie/massive-js/subscribers","subscription_url":"https://api.github.com/repos/benjie/massive-js/subscription","commits_url":"https://api.github.com/repos/benjie/massive-js/commits{/sha}","git_commits_url":"https://api.github.com/repos/benjie/massive-js/git/commits{/sha}","comments_url":"https://api.github.com/repos/benjie/massive-js/comments{/number}","issue_comment_url":"https://api.github.com/repos/benjie/massive-js/issues/comments{/number}","contents_url":"https://api.github.com/repos/benjie/massive-js/contents/{+path}","compare_url":"https://api.github.com/repos/benjie/massive-js/compare/{base}...{head}","merges_url":"https://api.github.com/repos/benjie/massive-js/merges","archive_url":"https://api.github.com/repos/benjie/massive-js/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/benjie/massive-js/downloads","issues_url":"https://api.github.com/repos/benjie/massive-js/issues{/number}","pulls_url":"https://api.github.com/repos/benjie/massive-js/pulls{/number}","milestones_url":"https://api.github.com/repos/benjie/massive-js/milestones{/number}","notifications_url":"https://api.github.com/repos/benjie/massive-js/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/benjie/massive-js/labels{/name}","releases_url":"https://api.github.com/repos/benjie/massive-js/releases{/id}","deployments_url":"https://api.github.com/repos/benjie/massive-js/deployments","created_at":"2016-07-24T11:02:28Z","updated_at":"2016-07-24T11:02:29Z","pushed_at":"2016-08-01T07:37:11Z","git_url":"git://github.com/benjie/massive-js.git","ssh_url":"git@github.com:benjie/massive-js.git","clone_url":"https://github.com/benjie/massive-js.git","svn_url":"https://github.com/benjie/massive-js","homepage":"","size":928,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"robconery:master","ref":"master","sha":"07b4509941ef82155834409b06bc6377937d257e","user":{"login":"robconery","id":78586,"avatar_url":"https://avatars.githubusercontent.com/u/78586?v=3","gravatar_id":"","url":"https://api.github.com/users/robconery","html_url":"https://github.com/robconery","followers_url":"https://api.github.com/users/robconery/followers","following_url":"https://api.github.com/users/robconery/following{/other_user}","gists_url":"https://api.github.com/users/robconery/gists{/gist_id}","starred_url":"https://api.github.com/users/robconery/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/robconery/subscriptions","organizations_url":"https://api.github.com/users/robconery/orgs","repos_url":"https://api.github.com/users/robconery/repos","events_url":"https://api.github.com/users/robconery/events{/privacy}","received_events_url":"https://api.github.com/users/robconery/received_events","type":"User","site_admin":false},"repo":{"id":4154667,"name":"massive-js","full_name":"robconery/massive-js","owner":{"login":"robconery","id":78586,"avatar_url":"https://avatars.githubusercontent.com/u/78586?v=3","gravatar_id":"","url":"https://api.github.com/users/robconery","html_url":"https://github.com/robconery","followers_url":"https://api.github.com/users/robconery/followers","following_url":"https://api.github.com/users/robconery/following{/other_user}","gists_url":"https://api.github.com/users/robconery/gists{/gist_id}","starred_url":"https://api.github.com/users/robconery/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/robconery/subscriptions","organizations_url":"https://api.github.com/users/robconery/orgs","repos_url":"https://api.github.com/users/robconery/repos","events_url":"https://api.github.com/users/robconery/events{/privacy}","received_events_url":"https://api.github.com/users/robconery/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/robconery/massive-js","description":"A simple relational data access tool for NodeJS. ","fork":false,"url":"https://api.github.com/repos/robconery/massive-js","forks_url":"https://api.github.com/repos/robconery/massive-js/forks","keys_url":"https://api.github.com/repos/robconery/massive-js/keys{/key_id}","collaborators_url":"https://api.github.com/repos/robconery/massive-js/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/robconery/massive-js/teams","hooks_url":"https://api.github.com/repos/robconery/massive-js/hooks","issue_events_url":"https://api.github.com/repos/robconery/massive-js/issues/events{/number}","events_url":"https://api.github.com/repos/robconery/massive-js/events","assignees_url":"https://api.github.com/repos/robconery/massive-js/assignees{/user}","branches_url":"https://api.github.com/repos/robconery/massive-js/branches{/branch}","tags_url":"https://api.github.com/repos/robconery/massive-js/tags","blobs_url":"https://api.github.com/repos/robconery/massive-js/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/robconery/massive-js/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/robconery/massive-js/git/refs{/sha}","trees_url":"https://api.github.com/repos/robconery/massive-js/git/trees{/sha}","statuses_url":"https://api.github.com/repos/robconery/massive-js/statuses/{sha}","languages_url":"https://api.github.com/repos/robconery/massive-js/languages","stargazers_url":"https://api.github.com/repos/robconery/massive-js/stargazers","contributors_url":"https://api.github.com/repos/robconery/massive-js/contributors","subscribers_url":"https://api.github.com/repos/robconery/massive-js/subscribers","subscription_url":"https://api.github.com/repos/robconery/massive-js/subscription","commits_url":"https://api.github.com/repos/robconery/massive-js/commits{/sha}","git_commits_url":"https://api.github.com/repos/robconery/massive-js/git/commits{/sha}","comments_url":"https://api.github.com/repos/robconery/massive-js/comments{/number}","issue_comment_url":"https://api.github.com/repos/robconery/massive-js/issues/comments{/number}","contents_url":"https://api.github.com/repos/robconery/massive-js/contents/{+path}","compare_url":"https://api.github.com/repos/robconery/massive-js/compare/{base}...{head}","merges_url":"https://api.github.com/repos/robconery/massive-js/merges","archive_url":"https://api.github.com/repos/robconery/massive-js/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/robconery/massive-js/downloads","issues_url":"https://api.github.com/repos/robconery/massive-js/issues{/number}","pulls_url":"https://api.github.com/repos/robconery/massive-js/pulls{/number}","milestones_url":"https://api.github.com/repos/robconery/massive-js/milestones{/number}","notifications_url":"https://api.github.com/repos/robconery/massive-js/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/robconery/massive-js/labels{/name}","releases_url":"https://api.github.com/repos/robconery/massive-js/releases{/id}","deployments_url":"https://api.github.com/repos/robconery/massive-js/deployments","created_at":"2012-04-27T03:25:03Z","updated_at":"2016-07-30T19:54:02Z","pushed_at":"2016-08-01T07:41:09Z","git_url":"git://github.com/robconery/massive-js.git","ssh_url":"git@github.com:robconery/massive-js.git","clone_url":"https://github.com/robconery/massive-js.git","svn_url":"https://github.com/robconery/massive-js","homepage":"","size":969,"stargazers_count":1345,"watchers_count":1345,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":113,"mirror_url":null,"open_issues_count":25,"forks":113,"open_issues":25,"watchers":1345,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/robconery/massive-js/pulls/297"},"html":{"href":"https://github.com/robconery/massive-js/pull/297"},"issue":{"href":"https://api.github.com/repos/robconery/massive-js/issues/297"},"comments":{"href":"https://api.github.com/repos/robconery/massive-js/issues/297/comments"},"review_comments":{"href":"https://api.github.com/repos/robconery/massive-js/pulls/297/comments"},"review_comment":{"href":"https://api.github.com/repos/robconery/massive-js/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/robconery/massive-js/pulls/297/commits"},"statuses":{"href":"https://api.github.com/repos/robconery/massive-js/statuses/b96587ca6da6c0f7d200e37e44ab7c905c8ab4a1"}},"merged":false,"mergeable":true,"mergeable_state":"clean","merged_by":null,"comments":0,"review_comments":0,"commits":4,"additions":199,"deletions":143,"changed_files":3}}
{"actor":{"display_login":"benjie"}}