From a8ec072cdc6b1d0389e4db0da3fe03808da7098d Mon Sep 17 00:00:00 2001 From: Benjamin Pannell Date: Fri, 10 Jan 2014 17:02:16 +0200 Subject: [PATCH] Added Database.close() and Database.disconnect() methods to allow graceful closing of DB connections --- lib/Database.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/Database.js b/lib/Database.js index 52bcfaa..39fff84 100644 --- a/lib/Database.js +++ b/lib/Database.js @@ -58,6 +58,12 @@ Database.prototype.connect = function (cb) { }); }; +Database.prototype.close = Database.prototype.disconnect = function() { + if(!this.connection) return; + this.connection.close(); + this.connection = null; + }; + Database.prototype.express = function() { /// Creates an Express Middleware which will make this database wrapper available through the req.db property ///