From 54682771efdd2db45cd4e73b4068d6c637f947fd Mon Sep 17 00:00:00 2001 From: Pierre Brisorgueil Date: Wed, 25 Mar 2020 16:05:27 +0100 Subject: [PATCH] =?UTF-8?q?feat(apis):=20add=20updated=20at=20date=20?= =?UTF-8?q?=E2=9C=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/helpers/montaineSave.js | 4 ++-- modules/apis/repositories/apis.repository.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/helpers/montaineSave.js b/lib/helpers/montaineSave.js index 882c0ccc8..2df08638c 100644 --- a/lib/helpers/montaineSave.js +++ b/lib/helpers/montaineSave.js @@ -29,7 +29,7 @@ const prepareSave = (object, date) => { * @param {object} object - object to prepare * @return {[object]} [object] - array of action for insert in mongoose */ -const prepareMongoose = (object) => { +const prepareMongoose = (object, date) => { const filter = {}; const arrays = []; const edits = []; @@ -73,7 +73,7 @@ const prepareMongoose = (object) => { const init = { filter, update: { - $set: filter, + $set: { ...filter, ...{ updatedAt: date } }, }, upsert: true, }; diff --git a/modules/apis/repositories/apis.repository.js b/modules/apis/repositories/apis.repository.js index a3dc660ba..4d4ec4570 100644 --- a/modules/apis/repositories/apis.repository.js +++ b/modules/apis/repositories/apis.repository.js @@ -89,5 +89,5 @@ exports.getApiData = (collection) => { model = mongoose.model(collection, _schema); } - return model.find().sort('-createdAt').exec(); + return model.find().sort('-updatedAt').exec(); };