Skip to content

Commit

Permalink
Fix invalid reference to persist (fixes #5)
Browse files Browse the repository at this point in the history
  • Loading branch information
notheotherben committed Nov 7, 2013
1 parent 28be469 commit 912b8ca
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions lib/orm-timestamps.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,21 +44,21 @@ function Plugin(db, opts) {

if(opts.timestamp !== true) return;

if(persist && options.createdProperty !== false)
if(options.persist && options.createdProperty !== false)
properties[options.createdProperty] = options.dbtype;
if(persist && options.modifiedProperty !== false)
if(options.persist && options.modifiedProperty !== false)
properties[options.modifiedProperty] = options.dbtype;

opts.hooks = opts.hooks || {};

if(options.createdProperty !== false)
wrapHook(opts.hooks, 'beforeCreate', function() {
if(!persist && this[options.createdProperty] === undefined)
if(options.persist)
this[options.createdProperty] = options.now();
else if(this[options.createdProperty] === undefined)
Object.defineProperty(this, options.createdProperty, {
value: options.now()
})
else if(persist)
this[options.createdProperty] = options.now();
});
});

if(options.modifiedProperty !== false)
Expand Down

0 comments on commit 912b8ca

Please sign in to comment.