Created
July 22, 2013 14:38
-
-
Save cheeyeo/6054320 to your computer and use it in GitHub Desktop.
Connecting to MongoHQ using Elixir on Heroku
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# uses the mongoex plugin | |
if System.get_env("MONGOHQ_URL") !== nil do | |
connection = URI.parse( System.get_env("MONGOHQ_URL") ) | |
host = '#{connection.host}' | |
port = connection.port | |
userinfo = String.split( connection.userinfo, ":" ) | |
username = Enum.at(userinfo,0) | |
password = Enum.at(userinfo,1) | |
pool = 4 | |
database = binary_to_atom( String.replace(connection.path,"/","") ) | |
Mongoex.Server.setup(address: host, port: port, database: database, pool: pool, username: username, password: password) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment