From 058780832c89ea1147dcfa30f87e4b708a594408 Mon Sep 17 00:00:00 2001 From: Benjamin Pannell Date: Tue, 1 Jul 2014 17:26:31 +0200 Subject: [PATCH] Added support for overriding options on a per-table basis --- lib/orm-timestamps.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/orm-timestamps.js b/lib/orm-timestamps.js index ddd72d9..b6da479 100644 --- a/lib/orm-timestamps.js +++ b/lib/orm-timestamps.js @@ -1,5 +1,5 @@ function Plugin(db, opts) { - var options = { + var defaults = { createdProperty: 'created_at', modifiedProperty: 'modified_at', expiresProperty: false, @@ -51,8 +51,11 @@ function Plugin(db, opts) { } function monitor(name, properties, opts) { + if(!opts.timestamp) return; - if(opts.timestamp !== true) return; + var options = defaults; + if(typeof opts.timestamp == 'object') + options = extend(defaults, opts.timestamp); if(options.persist && options.createdProperty !== false) properties[options.createdProperty] = options.dbtype; @@ -84,8 +87,7 @@ function Plugin(db, opts) { }); } - - options = extend(options, opts); + defaults = extend(defaults, opts); return { beforeDefine: monitor