From 1339af11ae0bd101ecbaf892856137080ee4572a Mon Sep 17 00:00:00 2001 From: Rory Powell Date: Wed, 30 Mar 2022 14:24:04 +0100 Subject: [PATCH] Add createdAt and updatedAt to all new put requests --- packages/backend-core/src/db/index.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/backend-core/src/db/index.js b/packages/backend-core/src/db/index.js index cc5eaaf9c5..eb837dc254 100644 --- a/packages/backend-core/src/db/index.js +++ b/packages/backend-core/src/db/index.js @@ -6,9 +6,11 @@ let initialised = false const put = dbPut => async (doc, options = {}) => { - const response = await dbPut(doc, options) - // TODO: add created / updated - return response + if (!doc.createdAt) { + doc.createdAt = new Date().toISOString() + } + doc.updatedAt = new Date().toISOString() + return dbPut(doc, options) } const checkInitialised = () => {