Commit d6aa6c0c authored by andreagerino's avatar andreagerino

...

parent ff19571c
...@@ -11,12 +11,13 @@ var assert = assert = require('assert'); ...@@ -11,12 +11,13 @@ var assert = assert = require('assert');
var mongoUrl = 'mongodb://icarus:icarus@localhost:27017/icarus'; var mongoUrl = 'mongodb://icarus:icarus@localhost:27017/icarus';
//Use connect method to test the connection to the Server //Use connect method to test the connection to the Server
var mongoDb;
mongoClient.connect(mongoUrl, function(err, db) { mongoClient.connect(mongoUrl, function(err, db) {
assert.equal(null, err, err); assert.equal(null, err, err);
debug("Connected to MongoDB database: "+db.databaseName); debug("Connected to MongoDB database: "+db.databaseName);
db.close(); mongoDb = db;
}); });
...@@ -29,8 +30,6 @@ router.get('/:resource_id', function(req, res, next) { ...@@ -29,8 +30,6 @@ router.get('/:resource_id', function(req, res, next) {
debug(err); debug(err);
next(err); next(err);
db.close();
}else{ }else{
var collection = db.collection('resources'); var collection = db.collection('resources');
...@@ -57,8 +56,6 @@ router.get('/:resource_id', function(req, res, next) { ...@@ -57,8 +56,6 @@ router.get('/:resource_id', function(req, res, next) {
} }
db.close();
}); });
} }
...@@ -76,8 +73,6 @@ router.post('/', function(req, res, next){ ...@@ -76,8 +73,6 @@ router.post('/', function(req, res, next){
debug(err); debug(err);
next(err); next(err);
db.close();
}else{ }else{
var collection = db.collection('resources'); var collection = db.collection('resources');
...@@ -94,7 +89,6 @@ router.post('/', function(req, res, next){ ...@@ -94,7 +89,6 @@ router.post('/', function(req, res, next){
} else { } else {
db.close();
res.statusCode = 201; res.statusCode = 201;
res.send({"_id":r.insertedId}); res.send({"_id":r.insertedId});
...@@ -110,8 +104,6 @@ router.post('/', function(req, res, next){ ...@@ -110,8 +104,6 @@ router.post('/', function(req, res, next){
debug(error); debug(error);
next(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