From fb44c243f0914536ca0485de3845e80fd5007084 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Lal?= Date: Thu, 31 Oct 2013 14:12:02 +0100 Subject: [PATCH] Use the new model.tableName to get the collection name --- lib/mongodb.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/mongodb.js b/lib/mongodb.js index 685fb6e..1aed537 100644 --- a/lib/mongodb.js +++ b/lib/mongodb.js @@ -108,10 +108,8 @@ MongoDB.prototype.defineForeignKey = function (model, key, cb) { cb(null, MongoObjectID); }; -MongoDB.prototype.collection = function (name) { - if ("undefined" !== typeof (this._models[name].settings.table)) { - name = this._models[name].settings.table; - } +MongoDB.prototype.collection = function (model) { + var name = this.table(model); if (!this.collections[name]) { this.collections[name] = new mongodb.Collection(this.client, name); } @@ -294,3 +292,6 @@ MongoDB.prototype.disconnect = function () { this.client.close(); }; +MongoDB.prototype.table = function(model) { + return this._models[model].model.tableName; +};