catch mongodb-native errors

This commit is contained in:
Ritchie Martori
2011-11-27 09:17:21 -08:00
parent c4265ff3ce
commit 08f94f8552
2 changed files with 7 additions and 4 deletions

View File

@@ -1,7 +1,7 @@
var express = require('express')
, app = express.createServer()
, db = require('./db').db
, mongoStore = require('connect-mongodb');
, MongoStore = require('connect-mongodb');
;
// expose the app as a module so everyone can use it
@@ -34,7 +34,7 @@ app.configure(function(){
secret: 'secret',
key: 'deployd.sid',
cookie: {httpOnly: false},
store: new mongoStore({db: db})
store: new MongoStore({db: db})
}));
app.use(app.router);
app.use(express.static(__dirname + '/../public'));

View File

@@ -90,8 +90,11 @@ module.exports = {
collection(db, model, function(err, collection) {
var index = {};
index[property] = 1;
collection.ensureIndex(index, options, fn);
try {
collection.ensureIndex(index, options, fn);
} catch(e) {
console.error('MongoError:', e);
}
});
})