Heroku + Node.js + MongoHQ + expressjs

时间:2011-08-06 10:42:40

标签: mongodb node.js heroku express mongohq

我尝试将Heroku与Mongo一起用于Express.js项目。挣扎着连接到mongohq。记录输出:

connstring是:mongodb:// heroku:XXXXXXXXXXXXXXXXXXXXXXXXX @staff.mongohq.com:10073 / app676842 主持人是:staff.mongohq.com

app.configure(function() {
  app.set('connstring', process.env.MONGOHQ_URL 
          || ('mongodb://' + app.set('m_host') + '/' +    app.set('m_database')));
  console.log('connstring is: ' + app.set('connstring'));
  var uri = parseUri(app.set('connstring'));
  console.log('host is: ' + uri.host);
  app.use(express.bodyParser());
  app.use(express.cookieParser());

  // use connect-mongo as session middleware
  app.use(express.session({
    secret: 'topsecret',
    store: new store({ db: app.set('m_database'), host: uri.host })
  }));
  app.use(express.methodOverride());
  app.use(app.router);

  // use express logger
  app.use(express.logger({ format: '\x1b[1m:method\x1b[0m \x1b[33m:url\x1b[0m :response-time ms' }));
  app.use(express.static(__dirname + '/public'));
});

1 个答案:

答案 0 :(得分:6)

您是否设置了密码?

尝试将连接字符串更改为:

  

的mongodb:// Heroku的:的你的密码 @ staff.mongohq.com:10073 / app676842

假设您的用户名设置为“heroku”