Skip to content

Commit

Permalink
Added support for overriding options on a per-table basis
Browse files Browse the repository at this point in the history
  • Loading branch information
notheotherben committed Jul 1, 2014
1 parent 9a798ad commit 0587808
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions lib/orm-timestamps.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
function Plugin(db, opts) {
var options = {
var defaults = {
createdProperty: 'created_at',
modifiedProperty: 'modified_at',
expiresProperty: false,
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -84,8 +87,7 @@ function Plugin(db, opts) {
});
}


options = extend(options, opts);
defaults = extend(defaults, opts);

return {
beforeDefine: monitor
Expand Down

0 comments on commit 0587808

Please sign in to comment.