From 9d153d5db6a29556f56f7b3aeda2e7eeaa13af6d Mon Sep 17 00:00:00 2001 From: Jim Rollenhagen Date: Sun, 16 Aug 2015 07:13:48 -0700 Subject: [PATCH] Set updated field on instance create To be more in line with how other frameworks implement this behavior, and for application sanity, set the "updated at" field during beforeInsert. Closes #1 --- lib/behavior/events.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/behavior/events.js b/lib/behavior/events.js index 885ce3a..ec238fa 100644 --- a/lib/behavior/events.js +++ b/lib/behavior/events.js @@ -9,6 +9,11 @@ events.beforeInsert = function() { // Set value for created field. this.set(behaviorData.createdFieldName, new Date()); } + + // ditto for updatedAt + if (behaviorData.hasUpdatedField) { + this.set(behaviorData.updatedFieldName, new Date()); + } }; events.beforeUpdate = function() {