mirror of
https://github.com/HackPlan/RootPanel.git
synced 2026-04-24 03:35:59 +08:00
17 lines
356 B
CoffeeScript
17 lines
356 B
CoffeeScript
{config} = app
|
|
{mongoose} = app.libs
|
|
|
|
{user, password, host, name} = config.mongodb
|
|
|
|
if user and password
|
|
mongodb_uri = "mongodb://#{user}:#{password}@#{host}/#{name}"
|
|
else
|
|
mongodb_uri = "mongodb://#{host}/#{name}"
|
|
|
|
mongoose.connect mongodb_uri
|
|
|
|
mongoose.connection.on 'error', (err) ->
|
|
console.error err if err
|
|
|
|
module.exports = mongoose.connection
|