{"action":"opened","issue":{"url":"https://api.github.com/repos/hapijs/discuss/issues/182","labels_url":"https://api.github.com/repos/hapijs/discuss/issues/182/labels{/name}","comments_url":"https://api.github.com/repos/hapijs/discuss/issues/182/comments","events_url":"https://api.github.com/repos/hapijs/discuss/issues/182/events","html_url":"https://github.com/hapijs/discuss/issues/182","id":113256568,"number":182,"title":"How to pass a database connection to plugins?","user":{"login":"electerious","id":499088,"avatar_url":"https://avatars.githubusercontent.com/u/499088?v=3","gravatar_id":"","url":"https://api.github.com/users/electerious","html_url":"https://github.com/electerious","followers_url":"https://api.github.com/users/electerious/followers","following_url":"https://api.github.com/users/electerious/following{/other_user}","gists_url":"https://api.github.com/users/electerious/gists{/gist_id}","starred_url":"https://api.github.com/users/electerious/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/electerious/subscriptions","organizations_url":"https://api.github.com/users/electerious/orgs","repos_url":"https://api.github.com/users/electerious/repos","events_url":"https://api.github.com/users/electerious/events{/privacy}","received_events_url":"https://api.github.com/users/electerious/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-10-25T21:42:50Z","updated_at":"2015-10-25T21:42:50Z","closed_at":null,"body":"Hi,\r\n\r\nI'm trying to pass an open database connection to a Hapi plugin using the `options` property. The given connection is available inside the plugin, but it looks like the connection object has been passed to it as a value and not as a reference.\r\n\r\n```js\r\n// Server\r\nserver.register([{\r\n\tregister : require(nodePath),\r\n\toptions  : { connection }\r\n}], options, next)\r\n```\r\n\r\n```js\r\n// Plugin\r\n// […]\r\nplugin = function(server, options, next) {\r\n\tconsole.log(options.connection) // => Works fine\r\n}\r\n// […]\r\n```\r\n\r\nrethinkdb throws the following error:\r\n\r\n```\r\nUnhandled rejection ReqlDriverError: First argument to `run` must be an open connection.\r\n```\r\n\r\nWhat's the best way to pass a connection to a plugin?\r\n\r\nHapi Version: 11.0.2\r\n\r\nThanks for the help."}}