Skip to content

Instantly share code, notes, and snippets.

@williamchang73
Created November 28, 2014 10:21
Show Gist options
  • Save williamchang73/aee7db94c5ff430f4da6 to your computer and use it in GitHub Desktop.
Save williamchang73/aee7db94c5ff430f4da6 to your computer and use it in GitHub Desktop.
loopback for auto populate created / modified time
module.exports = function(Base) {
Base.beforeCreate = function (next, data)
{
this.created = new Date();
this.modified = new Date();
next();
};
Base.beforeSave = function (next, data)
{
this.modified = new Date();
next();
};
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment