Skip to content

Commit

Permalink
Merge pull request #1055 from HDRUK/SUPP-1422_update_counter_without_…
Browse files Browse the repository at this point in the history
…timestamp

update counter in collection and dataset view without updatedAt field
  • Loading branch information
dnhdruk authored May 24, 2023
2 parents f553504 + d73d61c commit e809d73
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/resources/collections/collectioncounter.route.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const datasetLimiter = rateLimit({

router.post('/update', datasetLimiter, async (req, res) => {
const { id, counter } = req.body;
Collections.findOneAndUpdate({ id: { $eq: id } }, { counter }, err => {
Collections.findOneAndUpdate({ id: { $eq: id } }, { $set: { counter: counter } }, { timestamps: false }, err => {
if (err) return res.json({ success: false, error: err });
return res.json({ success: true });
});
Expand Down
4 changes: 2 additions & 2 deletions src/resources/tool/counter.route.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ router.post('/update', async (req, res) => {
const { id, counter } = req.body;

if (isNaN(id)) {
Data.findOneAndUpdate({ datasetid: { $eq: id } }, { counter }, err => {
Data.findOneAndUpdate({ datasetid: { $eq: id } }, { $set: { counter: counter } }, { timestamps: false }, err => {
if (err) return res.json({ success: false, error: err });
return res.json({ success: true });
});
} else {
Data.findOneAndUpdate({ id: { $eq: id } }, { counter }, err => {
Data.findOneAndUpdate({ id: { $eq: id } }, { $set: { counter: counter } }, { timestamps: false }, err => {
if (err) return res.json({ success: false, error: err });
return res.json({ success: true });
});
Expand Down

0 comments on commit e809d73

Please sign in to comment.