{"action":"opened","number":15,"pull_request":{"url":"https://api.github.com/repos/SamVerschueren/mongoose-seeder/pulls/15","id":199720723,"node_id":"MDExOlB1bGxSZXF1ZXN0MTk5NzIwNzIz","html_url":"https://github.com/SamVerschueren/mongoose-seeder/pull/15","diff_url":"https://github.com/SamVerschueren/mongoose-seeder/pull/15.diff","patch_url":"https://github.com/SamVerschueren/mongoose-seeder/pull/15.patch","issue_url":"https://api.github.com/repos/SamVerschueren/mongoose-seeder/issues/15","number":15,"state":"open","locked":false,"title":"Connection fix","user":{"login":"roblevy","id":4764631,"node_id":"MDQ6VXNlcjQ3NjQ2MzE=","avatar_url":"https://avatars0.githubusercontent.com/u/4764631?v=4","gravatar_id":"","url":"https://api.github.com/users/roblevy","html_url":"https://github.com/roblevy","followers_url":"https://api.github.com/users/roblevy/followers","following_url":"https://api.github.com/users/roblevy/following{/other_user}","gists_url":"https://api.github.com/users/roblevy/gists{/gist_id}","starred_url":"https://api.github.com/users/roblevy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/roblevy/subscriptions","organizations_url":"https://api.github.com/users/roblevy/orgs","repos_url":"https://api.github.com/users/roblevy/repos","events_url":"https://api.github.com/users/roblevy/events{/privacy}","received_events_url":"https://api.github.com/users/roblevy/received_events","type":"User","site_admin":false},"body":"This fixes [a problem](https://stackoverflow.com/q/51197989/2071807) with the way [models are scoped to a connection](http://mongoosejs.com/docs/connections.html#multiple_connections).\r\nThis fix applies to Mongoose 5 and also works with Mongoose 4.0.3.\r\n\r\nBy passing `seeder.seed` (and `_seed`) a connection object to which the models have been scoped, everything works nicely. I've updated the README to show how to use the new API.\r\n\r\n```\r\nmongoose.connect(dbUri).then(() => {\r\n  const Venue = require('../models/venue');\r\n  const Post = require('../models/post');\r\n  const User = require('../models/user');\r\n  const Course = require('../models/course');\r\n  seeder.seed(mongoose.connection, seedData, { dropDatabase: false, dropCollections: true }).then(dbData => {\r\n    console.log('seeded');\r\n  }).catch(err => {\r\n    console.log('Error when seeding', err);\r\n  }).finally(() => mongoose.connection.close());\r\n}, err => console.log(err));\r\n```","created_at":"2018-07-06T11:30:26Z","updated_at":"2018-07-06T11:30:26Z","closed_at":null,"merged_at":null,"merge_commit_sha":null,"assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/SamVerschueren/mongoose-seeder/pulls/15/commits","review_comments_url":"https://api.github.com/repos/SamVerschueren/mongoose-seeder/pulls/15/comments","review_comment_url":"https://api.github.com/repos/SamVerschueren/mongoose-seeder/pulls/comments{/number}","comments_url":"https://api.github.com/repos/SamVerschueren/mongoose-seeder/issues/15/comments","statuses_url":"https://api.github.com/repos/SamVerschueren/mongoose-seeder/statuses/53aa691c9ac36cbe66e008383afd8b46d9c28a0d","head":{"label":"roblevy:connection-fix","ref":"connection-fix","sha":"53aa691c9ac36cbe66e008383afd8b46d9c28a0d","user":{"login":"roblevy","id":4764631,"node_id":"MDQ6VXNlcjQ3NjQ2MzE=","avatar_url":"https://avatars0.githubusercontent.com/u/4764631?v=4","gravatar_id":"","url":"https://api.github.com/users/roblevy","html_url":"https://github.com/roblevy","followers_url":"https://api.github.com/users/roblevy/followers","following_url":"https://api.github.com/users/roblevy/following{/other_user}","gists_url":"https://api.github.com/users/roblevy/gists{/gist_id}","starred_url":"https://api.github.com/users/roblevy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/roblevy/subscriptions","organizations_url":"https://api.github.com/users/roblevy/orgs","repos_url":"https://api.github.com/users/roblevy/repos","events_url":"https://api.github.com/users/roblevy/events{/privacy}","received_events_url":"https://api.github.com/users/roblevy/received_events","type":"User","site_admin":false},"repo":{"id":139973499,"node_id":"MDEwOlJlcG9zaXRvcnkxMzk5NzM0OTk=","name":"mongoose-seeder","full_name":"roblevy/mongoose-seeder","owner":{"login":"roblevy","id":4764631,"node_id":"MDQ6VXNlcjQ3NjQ2MzE=","avatar_url":"https://avatars0.githubusercontent.com/u/4764631?v=4","gravatar_id":"","url":"https://api.github.com/users/roblevy","html_url":"https://github.com/roblevy","followers_url":"https://api.github.com/users/roblevy/followers","following_url":"https://api.github.com/users/roblevy/following{/other_user}","gists_url":"https://api.github.com/users/roblevy/gists{/gist_id}","starred_url":"https://api.github.com/users/roblevy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/roblevy/subscriptions","organizations_url":"https://api.github.com/users/roblevy/orgs","repos_url":"https://api.github.com/users/roblevy/repos","events_url":"https://api.github.com/users/roblevy/events{/privacy}","received_events_url":"https://api.github.com/users/roblevy/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/roblevy/mongoose-seeder","description":"Seed your MongoDB database easily","fork":true,"url":"https://api.github.com/repos/roblevy/mongoose-seeder","forks_url":"https://api.github.com/repos/roblevy/mongoose-seeder/forks","keys_url":"https://api.github.com/repos/roblevy/mongoose-seeder/keys{/key_id}","collaborators_url":"https://api.github.com/repos/roblevy/mongoose-seeder/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/roblevy/mongoose-seeder/teams","hooks_url":"https://api.github.com/repos/roblevy/mongoose-seeder/hooks","issue_events_url":"https://api.github.com/repos/roblevy/mongoose-seeder/issues/events{/number}","events_url":"https://api.github.com/repos/roblevy/mongoose-seeder/events","assignees_url":"https://api.github.com/repos/roblevy/mongoose-seeder/assignees{/user}","branches_url":"https://api.github.com/repos/roblevy/mongoose-seeder/branches{/branch}","tags_url":"https://api.github.com/repos/roblevy/mongoose-seeder/tags","blobs_url":"https://api.github.com/repos/roblevy/mongoose-seeder/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/roblevy/mongoose-seeder/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/roblevy/mongoose-seeder/git/refs{/sha}","trees_url":"https://api.github.com/repos/roblevy/mongoose-seeder/git/trees{/sha}","statuses_url":"https://api.github.com/repos/roblevy/mongoose-seeder/statuses/{sha}","languages_url":"https://api.github.com/repos/roblevy/mongoose-seeder/languages","stargazers_url":"https://api.github.com/repos/roblevy/mongoose-seeder/stargazers","contributors_url":"https://api.github.com/repos/roblevy/mongoose-seeder/contributors","subscribers_url":"https://api.github.com/repos/roblevy/mongoose-seeder/subscribers","subscription_url":"https://api.github.com/repos/roblevy/mongoose-seeder/subscription","commits_url":"https://api.github.com/repos/roblevy/mongoose-seeder/commits{/sha}","git_commits_url":"https://api.github.com/repos/roblevy/mongoose-seeder/git/commits{/sha}","comments_url":"https://api.github.com/repos/roblevy/mongoose-seeder/comments{/number}","issue_comment_url":"https://api.github.com/repos/roblevy/mongoose-seeder/issues/comments{/number}","contents_url":"https://api.github.com/repos/roblevy/mongoose-seeder/contents/{+path}","compare_url":"https://api.github.com/repos/roblevy/mongoose-seeder/compare/{base}...{head}","merges_url":"https://api.github.com/repos/roblevy/mongoose-seeder/merges","archive_url":"https://api.github.com/repos/roblevy/mongoose-seeder/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/roblevy/mongoose-seeder/downloads","issues_url":"https://api.github.com/repos/roblevy/mongoose-seeder/issues{/number}","pulls_url":"https://api.github.com/repos/roblevy/mongoose-seeder/pulls{/number}","milestones_url":"https://api.github.com/repos/roblevy/mongoose-seeder/milestones{/number}","notifications_url":"https://api.github.com/repos/roblevy/mongoose-seeder/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/roblevy/mongoose-seeder/labels{/name}","releases_url":"https://api.github.com/repos/roblevy/mongoose-seeder/releases{/id}","deployments_url":"https://api.github.com/repos/roblevy/mongoose-seeder/deployments","created_at":"2018-07-06T10:59:15Z","updated_at":"2018-07-06T10:59:17Z","pushed_at":"2018-07-06T11:16:57Z","git_url":"git://github.com/roblevy/mongoose-seeder.git","ssh_url":"git@github.com:roblevy/mongoose-seeder.git","clone_url":"https://github.com/roblevy/mongoose-seeder.git","svn_url":"https://github.com/roblevy/mongoose-seeder","homepage":null,"size":37,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"SamVerschueren:master","ref":"master","sha":"ea08d510228a76e5eafa08e1f94cbe8cf0a6614d","user":{"login":"SamVerschueren","id":1913805,"node_id":"MDQ6VXNlcjE5MTM4MDU=","avatar_url":"https://avatars2.githubusercontent.com/u/1913805?v=4","gravatar_id":"","url":"https://api.github.com/users/SamVerschueren","html_url":"https://github.com/SamVerschueren","followers_url":"https://api.github.com/users/SamVerschueren/followers","following_url":"https://api.github.com/users/SamVerschueren/following{/other_user}","gists_url":"https://api.github.com/users/SamVerschueren/gists{/gist_id}","starred_url":"https://api.github.com/users/SamVerschueren/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SamVerschueren/subscriptions","organizations_url":"https://api.github.com/users/SamVerschueren/orgs","repos_url":"https://api.github.com/users/SamVerschueren/repos","events_url":"https://api.github.com/users/SamVerschueren/events{/privacy}","received_events_url":"https://api.github.com/users/SamVerschueren/received_events","type":"User","site_admin":false},"repo":{"id":32034046,"node_id":"MDEwOlJlcG9zaXRvcnkzMjAzNDA0Ng==","name":"mongoose-seeder","full_name":"SamVerschueren/mongoose-seeder","owner":{"login":"SamVerschueren","id":1913805,"node_id":"MDQ6VXNlcjE5MTM4MDU=","avatar_url":"https://avatars2.githubusercontent.com/u/1913805?v=4","gravatar_id":"","url":"https://api.github.com/users/SamVerschueren","html_url":"https://github.com/SamVerschueren","followers_url":"https://api.github.com/users/SamVerschueren/followers","following_url":"https://api.github.com/users/SamVerschueren/following{/other_user}","gists_url":"https://api.github.com/users/SamVerschueren/gists{/gist_id}","starred_url":"https://api.github.com/users/SamVerschueren/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SamVerschueren/subscriptions","organizations_url":"https://api.github.com/users/SamVerschueren/orgs","repos_url":"https://api.github.com/users/SamVerschueren/repos","events_url":"https://api.github.com/users/SamVerschueren/events{/privacy}","received_events_url":"https://api.github.com/users/SamVerschueren/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/SamVerschueren/mongoose-seeder","description":"Seed your MongoDB database easily","fork":false,"url":"https://api.github.com/repos/SamVerschueren/mongoose-seeder","forks_url":"https://api.github.com/repos/SamVerschueren/mongoose-seeder/forks","keys_url":"https://api.github.com/repos/SamVerschueren/mongoose-seeder/keys{/key_id}","collaborators_url":"https://api.github.com/repos/SamVerschueren/mongoose-seeder/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/SamVerschueren/mongoose-seeder/teams","hooks_url":"https://api.github.com/repos/SamVerschueren/mongoose-seeder/hooks","issue_events_url":"https://api.github.com/repos/SamVerschueren/mongoose-seeder/issues/events{/number}","events_url":"https://api.github.com/repos/SamVerschueren/mongoose-seeder/events","assignees_url":"https://api.github.com/repos/SamVerschueren/mongoose-seeder/assignees{/user}","branches_url":"https://api.github.com/repos/SamVerschueren/mongoose-seeder/branches{/branch}","tags_url":"https://api.github.com/repos/SamVerschueren/mongoose-seeder/tags","blobs_url":"https://api.github.com/repos/SamVerschueren/mongoose-seeder/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/SamVerschueren/mongoose-seeder/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/SamVerschueren/mongoose-seeder/git/refs{/sha}","trees_url":"https://api.github.com/repos/SamVerschueren/mongoose-seeder/git/trees{/sha}","statuses_url":"https://api.github.com/repos/SamVerschueren/mongoose-seeder/statuses/{sha}","languages_url":"https://api.github.com/repos/SamVerschueren/mongoose-seeder/languages","stargazers_url":"https://api.github.com/repos/SamVerschueren/mongoose-seeder/stargazers","contributors_url":"https://api.github.com/repos/SamVerschueren/mongoose-seeder/contributors","subscribers_url":"https://api.github.com/repos/SamVerschueren/mongoose-seeder/subscribers","subscription_url":"https://api.github.com/repos/SamVerschueren/mongoose-seeder/subscription","commits_url":"https://api.github.com/repos/SamVerschueren/mongoose-seeder/commits{/sha}","git_commits_url":"https://api.github.com/repos/SamVerschueren/mongoose-seeder/git/commits{/sha}","comments_url":"https://api.github.com/repos/SamVerschueren/mongoose-seeder/comments{/number}","issue_comment_url":"https://api.github.com/repos/SamVerschueren/mongoose-seeder/issues/comments{/number}","contents_url":"https://api.github.com/repos/SamVerschueren/mongoose-seeder/contents/{+path}","compare_url":"https://api.github.com/repos/SamVerschueren/mongoose-seeder/compare/{base}...{head}","merges_url":"https://api.github.com/repos/SamVerschueren/mongoose-seeder/merges","archive_url":"https://api.github.com/repos/SamVerschueren/mongoose-seeder/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/SamVerschueren/mongoose-seeder/downloads","issues_url":"https://api.github.com/repos/SamVerschueren/mongoose-seeder/issues{/number}","pulls_url":"https://api.github.com/repos/SamVerschueren/mongoose-seeder/pulls{/number}","milestones_url":"https://api.github.com/repos/SamVerschueren/mongoose-seeder/milestones{/number}","notifications_url":"https://api.github.com/repos/SamVerschueren/mongoose-seeder/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/SamVerschueren/mongoose-seeder/labels{/name}","releases_url":"https://api.github.com/repos/SamVerschueren/mongoose-seeder/releases{/id}","deployments_url":"https://api.github.com/repos/SamVerschueren/mongoose-seeder/deployments","created_at":"2015-03-11T18:27:19Z","updated_at":"2018-02-18T18:51:47Z","pushed_at":"2018-06-03T20:26:08Z","git_url":"git://github.com/SamVerschueren/mongoose-seeder.git","ssh_url":"git@github.com:SamVerschueren/mongoose-seeder.git","clone_url":"https://github.com/SamVerschueren/mongoose-seeder.git","svn_url":"https://github.com/SamVerschueren/mongoose-seeder","homepage":null,"size":37,"stargazers_count":37,"watchers_count":37,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":13,"mirror_url":null,"archived":false,"open_issues_count":5,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":13,"open_issues":5,"watchers":37,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/SamVerschueren/mongoose-seeder/pulls/15"},"html":{"href":"https://github.com/SamVerschueren/mongoose-seeder/pull/15"},"issue":{"href":"https://api.github.com/repos/SamVerschueren/mongoose-seeder/issues/15"},"comments":{"href":"https://api.github.com/repos/SamVerschueren/mongoose-seeder/issues/15/comments"},"review_comments":{"href":"https://api.github.com/repos/SamVerschueren/mongoose-seeder/pulls/15/comments"},"review_comment":{"href":"https://api.github.com/repos/SamVerschueren/mongoose-seeder/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/SamVerschueren/mongoose-seeder/pulls/15/commits"},"statuses":{"href":"https://api.github.com/repos/SamVerschueren/mongoose-seeder/statuses/53aa691c9ac36cbe66e008383afd8b46d9c28a0d"}},"author_association":"NONE","merged":false,"mergeable":null,"rebaseable":null,"mergeable_state":"unknown","merged_by":null,"comments":0,"review_comments":0,"maintainer_can_modify":true,"commits":4,"additions":96,"deletions":88,"changed_files":4}}
{"actor":{"display_login":"roblevy"}}