From 3b9f2ca7c2fffa230bb0c6d4254a88deb9fbb023 Mon Sep 17 00:00:00 2001 From: Justin Reynolds Date: Thu, 5 Sep 2019 12:29:45 -0500 Subject: Fixes #2596 incorrect date types for created & updated --- models/actions.js | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'models/actions.js') diff --git a/models/actions.js b/models/actions.js index e9fa9114..8995d101 100644 --- a/models/actions.js +++ b/models/actions.js @@ -14,6 +14,16 @@ Actions.allow({ }, }); +Actions.before.insert((userId, doc) => { + doc.createdAt = new Date(); + doc.modifiedAt = doc.createdAt; +}); + +Actions.before.update((userId, doc, fieldNames, modifier) => { + modifier.$set = modifier.$set || {}; + modifier.$set.modifiedAt = new Date(); +}); + Actions.helpers({ description() { return this.desc; -- cgit v1.2.3-1-g7c22