Commit d6aa6c0c authored by andreagerino's avatar andreagerino

...

parent ff19571c
......@@ -11,12 +11,13 @@ var assert = assert = require('assert');
var mongoUrl = 'mongodb://icarus:icarus@localhost:27017/icarus';
//Use connect method to test the connection to the Server
var mongoDb;
mongoClient.connect(mongoUrl, function(err, db) {
assert.equal(null, err, err);
debug("Connected to MongoDB database: "+db.databaseName);
db.close();
mongoDb = db;
});
......@@ -29,8 +30,6 @@ router.get('/:resource_id', function(req, res, next) {
debug(err);
next(err);
db.close();
}else{
var collection = db.collection('resources');
......@@ -57,8 +56,6 @@ router.get('/:resource_id', function(req, res, next) {
}
db.close();
});
}
......@@ -76,8 +73,6 @@ router.post('/', function(req, res, next){
debug(err);
next(err);
db.close();
}else{
var collection = db.collection('resources');
......@@ -94,7 +89,6 @@ router.post('/', function(req, res, next){
} else {
db.close();
res.statusCode = 201;
res.send({"_id":r.insertedId});
......@@ -110,8 +104,6 @@ router.post('/', function(req, res, next){
debug(error);
next(error);
db.close();
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment