{"action":"created","comment":{"url":"https://api.github.com/repos/lob/hapi-bookshelf-models/pulls/comments/44820744","id":44820744,"diff_hunk":"@@ -1,13 +1,19 @@\n var fs    = require('fs');\n var Joi   = require('joi');\n+var glob  = require('glob');\n var path  = require('path');\n \n+var internals = {};\n+\n exports.register = function (server, options, next) {\n \n+  internals.bookshelf = null;\n+  internals.modelObjects = [];\n+\n   var schema = {\n     knex: Joi.object().required(),\n     plugins: Joi.array().includes(Joi.string()).default([]),\n-    models: Joi.string().required(),\n+    models: Joi.alternatives().try(Joi.string(), Joi.array()).required(),","path":"lib/index.js","position":17,"original_position":17,"commit_id":"47910fb609930a35cdd1c83300c9d15d66dd5af2","original_commit_id":"47910fb609930a35cdd1c83300c9d15d66dd5af2","user":{"login":"robinjoseph08","id":2454505,"avatar_url":"https://avatars.githubusercontent.com/u/2454505?v=3","gravatar_id":"","url":"https://api.github.com/users/robinjoseph08","html_url":"https://github.com/robinjoseph08","followers_url":"https://api.github.com/users/robinjoseph08/followers","following_url":"https://api.github.com/users/robinjoseph08/following{/other_user}","gists_url":"https://api.github.com/users/robinjoseph08/gists{/gist_id}","starred_url":"https://api.github.com/users/robinjoseph08/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/robinjoseph08/subscriptions","organizations_url":"https://api.github.com/users/robinjoseph08/orgs","repos_url":"https://api.github.com/users/robinjoseph08/repos","events_url":"https://api.github.com/users/robinjoseph08/events{/privacy}","received_events_url":"https://api.github.com/users/robinjoseph08/received_events","type":"User","site_admin":false},"body":"I think the better solution here would be to have `Joi.array().single().items(Joi.string()).required()`.\r\n\r\nThis would make it so the user can pass in either an array or a single item, but Joi would convert it into an array so you don't have to check it's type, you can just iterate over it. This will mean that you'll have to change the `Joi.assert` to a `Joi.validate` on line 22 as well.\r\n\r\nThis will allow for the case of a user passing in a array of non-glob directories (which you should have a test case for). Right now, your setup only allows for:\r\n\r\n1. a single directory\r\n2. a single glob\r\n3. an array of globs","created_at":"2015-11-13T19:07:10Z","updated_at":"2015-11-13T19:07:10Z","html_url":"https://github.com/lob/hapi-bookshelf-models/pull/16#discussion_r44820744","pull_request_url":"https://api.github.com/repos/lob/hapi-bookshelf-models/pulls/16","_links":{"self":{"href":"https://api.github.com/repos/lob/hapi-bookshelf-models/pulls/comments/44820744"},"html":{"href":"https://github.com/lob/hapi-bookshelf-models/pull/16#discussion_r44820744"},"pull_request":{"href":"https://api.github.com/repos/lob/hapi-bookshelf-models/pulls/16"}}},"pull_request":{"url":"https://api.github.com/repos/lob/hapi-bookshelf-models/pulls/16","id":48009968,"html_url":"https://github.com/lob/hapi-bookshelf-models/pull/16","diff_url":"https://github.com/lob/hapi-bookshelf-models/pull/16.diff","patch_url":"https://github.com/lob/hapi-bookshelf-models/pull/16.patch","issue_url":"https://api.github.com/repos/lob/hapi-bookshelf-models/issues/16","number":16,"state":"open","locked":false,"title":"Added glob to support wildcard model folder structure","user":{"login":"derbaeuerle","id":1363885,"avatar_url":"https://avatars.githubusercontent.com/u/1363885?v=3","gravatar_id":"","url":"https://api.github.com/users/derbaeuerle","html_url":"https://github.com/derbaeuerle","followers_url":"https://api.github.com/users/derbaeuerle/followers","following_url":"https://api.github.com/users/derbaeuerle/following{/other_user}","gists_url":"https://api.github.com/users/derbaeuerle/gists{/gist_id}","starred_url":"https://api.github.com/users/derbaeuerle/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/derbaeuerle/subscriptions","organizations_url":"https://api.github.com/users/derbaeuerle/orgs","repos_url":"https://api.github.com/users/derbaeuerle/repos","events_url":"https://api.github.com/users/derbaeuerle/events{/privacy}","received_events_url":"https://api.github.com/users/derbaeuerle/received_events","type":"User","site_admin":false},"body":"I tried to use hapi-bookshelf-models in my hapi application but with the lack of support of multidimensional folder structure for the models and wildcard model name definition there would was no reason for me to use this library.\r\nWith these changes you'll be able to use hapi-bookshelf-models as you know it or with support of an options.models array/string using glob syntax.\r\n\r\nIf there is anything wrong inside the code or opportunities for improvement, please let me know and i'll fix it.","created_at":"2015-10-18T14:52:44Z","updated_at":"2015-11-13T19:07:10Z","closed_at":null,"merged_at":null,"merge_commit_sha":"be11ce3fc5bee6bf51c1958d84f05b959eaa79f9","assignee":{"login":"mgartner","id":1128750,"avatar_url":"https://avatars.githubusercontent.com/u/1128750?v=3","gravatar_id":"","url":"https://api.github.com/users/mgartner","html_url":"https://github.com/mgartner","followers_url":"https://api.github.com/users/mgartner/followers","following_url":"https://api.github.com/users/mgartner/following{/other_user}","gists_url":"https://api.github.com/users/mgartner/gists{/gist_id}","starred_url":"https://api.github.com/users/mgartner/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mgartner/subscriptions","organizations_url":"https://api.github.com/users/mgartner/orgs","repos_url":"https://api.github.com/users/mgartner/repos","events_url":"https://api.github.com/users/mgartner/events{/privacy}","received_events_url":"https://api.github.com/users/mgartner/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/lob/hapi-bookshelf-models/pulls/16/commits","review_comments_url":"https://api.github.com/repos/lob/hapi-bookshelf-models/pulls/16/comments","review_comment_url":"https://api.github.com/repos/lob/hapi-bookshelf-models/pulls/comments{/number}","comments_url":"https://api.github.com/repos/lob/hapi-bookshelf-models/issues/16/comments","statuses_url":"https://api.github.com/repos/lob/hapi-bookshelf-models/statuses/47910fb609930a35cdd1c83300c9d15d66dd5af2","head":{"label":"derbaeuerle:master","ref":"master","sha":"47910fb609930a35cdd1c83300c9d15d66dd5af2","user":{"login":"derbaeuerle","id":1363885,"avatar_url":"https://avatars.githubusercontent.com/u/1363885?v=3","gravatar_id":"","url":"https://api.github.com/users/derbaeuerle","html_url":"https://github.com/derbaeuerle","followers_url":"https://api.github.com/users/derbaeuerle/followers","following_url":"https://api.github.com/users/derbaeuerle/following{/other_user}","gists_url":"https://api.github.com/users/derbaeuerle/gists{/gist_id}","starred_url":"https://api.github.com/users/derbaeuerle/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/derbaeuerle/subscriptions","organizations_url":"https://api.github.com/users/derbaeuerle/orgs","repos_url":"https://api.github.com/users/derbaeuerle/repos","events_url":"https://api.github.com/users/derbaeuerle/events{/privacy}","received_events_url":"https://api.github.com/users/derbaeuerle/received_events","type":"User","site_admin":false},"repo":{"id":44478196,"name":"hapi-bookshelf-models","full_name":"derbaeuerle/hapi-bookshelf-models","owner":{"login":"derbaeuerle","id":1363885,"avatar_url":"https://avatars.githubusercontent.com/u/1363885?v=3","gravatar_id":"","url":"https://api.github.com/users/derbaeuerle","html_url":"https://github.com/derbaeuerle","followers_url":"https://api.github.com/users/derbaeuerle/followers","following_url":"https://api.github.com/users/derbaeuerle/following{/other_user}","gists_url":"https://api.github.com/users/derbaeuerle/gists{/gist_id}","starred_url":"https://api.github.com/users/derbaeuerle/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/derbaeuerle/subscriptions","organizations_url":"https://api.github.com/users/derbaeuerle/orgs","repos_url":"https://api.github.com/users/derbaeuerle/repos","events_url":"https://api.github.com/users/derbaeuerle/events{/privacy}","received_events_url":"https://api.github.com/users/derbaeuerle/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/derbaeuerle/hapi-bookshelf-models","description":"","fork":true,"url":"https://api.github.com/repos/derbaeuerle/hapi-bookshelf-models","forks_url":"https://api.github.com/repos/derbaeuerle/hapi-bookshelf-models/forks","keys_url":"https://api.github.com/repos/derbaeuerle/hapi-bookshelf-models/keys{/key_id}","collaborators_url":"https://api.github.com/repos/derbaeuerle/hapi-bookshelf-models/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/derbaeuerle/hapi-bookshelf-models/teams","hooks_url":"https://api.github.com/repos/derbaeuerle/hapi-bookshelf-models/hooks","issue_events_url":"https://api.github.com/repos/derbaeuerle/hapi-bookshelf-models/issues/events{/number}","events_url":"https://api.github.com/repos/derbaeuerle/hapi-bookshelf-models/events","assignees_url":"https://api.github.com/repos/derbaeuerle/hapi-bookshelf-models/assignees{/user}","branches_url":"https://api.github.com/repos/derbaeuerle/hapi-bookshelf-models/branches{/branch}","tags_url":"https://api.github.com/repos/derbaeuerle/hapi-bookshelf-models/tags","blobs_url":"https://api.github.com/repos/derbaeuerle/hapi-bookshelf-models/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/derbaeuerle/hapi-bookshelf-models/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/derbaeuerle/hapi-bookshelf-models/git/refs{/sha}","trees_url":"https://api.github.com/repos/derbaeuerle/hapi-bookshelf-models/git/trees{/sha}","statuses_url":"https://api.github.com/repos/derbaeuerle/hapi-bookshelf-models/statuses/{sha}","languages_url":"https://api.github.com/repos/derbaeuerle/hapi-bookshelf-models/languages","stargazers_url":"https://api.github.com/repos/derbaeuerle/hapi-bookshelf-models/stargazers","contributors_url":"https://api.github.com/repos/derbaeuerle/hapi-bookshelf-models/contributors","subscribers_url":"https://api.github.com/repos/derbaeuerle/hapi-bookshelf-models/subscribers","subscription_url":"https://api.github.com/repos/derbaeuerle/hapi-bookshelf-models/subscription","commits_url":"https://api.github.com/repos/derbaeuerle/hapi-bookshelf-models/commits{/sha}","git_commits_url":"https://api.github.com/repos/derbaeuerle/hapi-bookshelf-models/git/commits{/sha}","comments_url":"https://api.github.com/repos/derbaeuerle/hapi-bookshelf-models/comments{/number}","issue_comment_url":"https://api.github.com/repos/derbaeuerle/hapi-bookshelf-models/issues/comments{/number}","contents_url":"https://api.github.com/repos/derbaeuerle/hapi-bookshelf-models/contents/{+path}","compare_url":"https://api.github.com/repos/derbaeuerle/hapi-bookshelf-models/compare/{base}...{head}","merges_url":"https://api.github.com/repos/derbaeuerle/hapi-bookshelf-models/merges","archive_url":"https://api.github.com/repos/derbaeuerle/hapi-bookshelf-models/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/derbaeuerle/hapi-bookshelf-models/downloads","issues_url":"https://api.github.com/repos/derbaeuerle/hapi-bookshelf-models/issues{/number}","pulls_url":"https://api.github.com/repos/derbaeuerle/hapi-bookshelf-models/pulls{/number}","milestones_url":"https://api.github.com/repos/derbaeuerle/hapi-bookshelf-models/milestones{/number}","notifications_url":"https://api.github.com/repos/derbaeuerle/hapi-bookshelf-models/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/derbaeuerle/hapi-bookshelf-models/labels{/name}","releases_url":"https://api.github.com/repos/derbaeuerle/hapi-bookshelf-models/releases{/id}","created_at":"2015-10-18T13:00:44Z","updated_at":"2015-10-18T13:00:45Z","pushed_at":"2015-10-18T14:56:34Z","git_url":"git://github.com/derbaeuerle/hapi-bookshelf-models.git","ssh_url":"git@github.com:derbaeuerle/hapi-bookshelf-models.git","clone_url":"https://github.com/derbaeuerle/hapi-bookshelf-models.git","svn_url":"https://github.com/derbaeuerle/hapi-bookshelf-models","homepage":"https://www.lob.com","size":112,"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":"lob:master","ref":"master","sha":"e853c2470ae11b0e578b547b1b60c27c16bf7b41","user":{"login":"lob","id":4955790,"avatar_url":"https://avatars.githubusercontent.com/u/4955790?v=3","gravatar_id":"","url":"https://api.github.com/users/lob","html_url":"https://github.com/lob","followers_url":"https://api.github.com/users/lob/followers","following_url":"https://api.github.com/users/lob/following{/other_user}","gists_url":"https://api.github.com/users/lob/gists{/gist_id}","starred_url":"https://api.github.com/users/lob/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lob/subscriptions","organizations_url":"https://api.github.com/users/lob/orgs","repos_url":"https://api.github.com/users/lob/repos","events_url":"https://api.github.com/users/lob/events{/privacy}","received_events_url":"https://api.github.com/users/lob/received_events","type":"Organization","site_admin":false},"repo":{"id":29359913,"name":"hapi-bookshelf-models","full_name":"lob/hapi-bookshelf-models","owner":{"login":"lob","id":4955790,"avatar_url":"https://avatars.githubusercontent.com/u/4955790?v=3","gravatar_id":"","url":"https://api.github.com/users/lob","html_url":"https://github.com/lob","followers_url":"https://api.github.com/users/lob/followers","following_url":"https://api.github.com/users/lob/following{/other_user}","gists_url":"https://api.github.com/users/lob/gists{/gist_id}","starred_url":"https://api.github.com/users/lob/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lob/subscriptions","organizations_url":"https://api.github.com/users/lob/orgs","repos_url":"https://api.github.com/users/lob/repos","events_url":"https://api.github.com/users/lob/events{/privacy}","received_events_url":"https://api.github.com/users/lob/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/lob/hapi-bookshelf-models","description":"","fork":false,"url":"https://api.github.com/repos/lob/hapi-bookshelf-models","forks_url":"https://api.github.com/repos/lob/hapi-bookshelf-models/forks","keys_url":"https://api.github.com/repos/lob/hapi-bookshelf-models/keys{/key_id}","collaborators_url":"https://api.github.com/repos/lob/hapi-bookshelf-models/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/lob/hapi-bookshelf-models/teams","hooks_url":"https://api.github.com/repos/lob/hapi-bookshelf-models/hooks","issue_events_url":"https://api.github.com/repos/lob/hapi-bookshelf-models/issues/events{/number}","events_url":"https://api.github.com/repos/lob/hapi-bookshelf-models/events","assignees_url":"https://api.github.com/repos/lob/hapi-bookshelf-models/assignees{/user}","branches_url":"https://api.github.com/repos/lob/hapi-bookshelf-models/branches{/branch}","tags_url":"https://api.github.com/repos/lob/hapi-bookshelf-models/tags","blobs_url":"https://api.github.com/repos/lob/hapi-bookshelf-models/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/lob/hapi-bookshelf-models/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/lob/hapi-bookshelf-models/git/refs{/sha}","trees_url":"https://api.github.com/repos/lob/hapi-bookshelf-models/git/trees{/sha}","statuses_url":"https://api.github.com/repos/lob/hapi-bookshelf-models/statuses/{sha}","languages_url":"https://api.github.com/repos/lob/hapi-bookshelf-models/languages","stargazers_url":"https://api.github.com/repos/lob/hapi-bookshelf-models/stargazers","contributors_url":"https://api.github.com/repos/lob/hapi-bookshelf-models/contributors","subscribers_url":"https://api.github.com/repos/lob/hapi-bookshelf-models/subscribers","subscription_url":"https://api.github.com/repos/lob/hapi-bookshelf-models/subscription","commits_url":"https://api.github.com/repos/lob/hapi-bookshelf-models/commits{/sha}","git_commits_url":"https://api.github.com/repos/lob/hapi-bookshelf-models/git/commits{/sha}","comments_url":"https://api.github.com/repos/lob/hapi-bookshelf-models/comments{/number}","issue_comment_url":"https://api.github.com/repos/lob/hapi-bookshelf-models/issues/comments{/number}","contents_url":"https://api.github.com/repos/lob/hapi-bookshelf-models/contents/{+path}","compare_url":"https://api.github.com/repos/lob/hapi-bookshelf-models/compare/{base}...{head}","merges_url":"https://api.github.com/repos/lob/hapi-bookshelf-models/merges","archive_url":"https://api.github.com/repos/lob/hapi-bookshelf-models/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/lob/hapi-bookshelf-models/downloads","issues_url":"https://api.github.com/repos/lob/hapi-bookshelf-models/issues{/number}","pulls_url":"https://api.github.com/repos/lob/hapi-bookshelf-models/pulls{/number}","milestones_url":"https://api.github.com/repos/lob/hapi-bookshelf-models/milestones{/number}","notifications_url":"https://api.github.com/repos/lob/hapi-bookshelf-models/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/lob/hapi-bookshelf-models/labels{/name}","releases_url":"https://api.github.com/repos/lob/hapi-bookshelf-models/releases{/id}","created_at":"2015-01-16T17:40:35Z","updated_at":"2015-10-02T19:37:59Z","pushed_at":"2015-10-18T14:56:35Z","git_url":"git://github.com/lob/hapi-bookshelf-models.git","ssh_url":"git@github.com:lob/hapi-bookshelf-models.git","clone_url":"https://github.com/lob/hapi-bookshelf-models.git","svn_url":"https://github.com/lob/hapi-bookshelf-models","homepage":"https://www.lob.com","size":328,"stargazers_count":16,"watchers_count":16,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":5,"mirror_url":null,"open_issues_count":1,"forks":5,"open_issues":1,"watchers":16,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/lob/hapi-bookshelf-models/pulls/16"},"html":{"href":"https://github.com/lob/hapi-bookshelf-models/pull/16"},"issue":{"href":"https://api.github.com/repos/lob/hapi-bookshelf-models/issues/16"},"comments":{"href":"https://api.github.com/repos/lob/hapi-bookshelf-models/issues/16/comments"},"review_comments":{"href":"https://api.github.com/repos/lob/hapi-bookshelf-models/pulls/16/comments"},"review_comment":{"href":"https://api.github.com/repos/lob/hapi-bookshelf-models/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/lob/hapi-bookshelf-models/pulls/16/commits"},"statuses":{"href":"https://api.github.com/repos/lob/hapi-bookshelf-models/statuses/47910fb609930a35cdd1c83300c9d15d66dd5af2"}}}}