question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

updatedAt not updating on save

See original GitHub issue

In 3.5, when I alter instance.name = 'Bob' and call instance.save(), the updatedAt is no longer updating. Is this the expected behaviour as this operation was previously working on 3.4

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

9reactions
janmeiercommented, Aug 8, 2015

@gcatto instance.changed('updatedAt', true) will mark the updatedAt column as dirty so it will be updated

1reaction
tonytampscommented, Sep 23, 2015

Sorry for thread necromancy, but just incase someone else is coming across this issue…

Sequelize (before version 3.5.0) would trigger a change on the updatedAt field regardless of what data was changed. So if we set model.nonExistantField = 'lol'; then model.save(), this would change the model.updatedAt but cause no actual update to the database.

Since 3.5.0, setting a field on the model that doesn’t exist will not trigger a change to the model.updatedAt.

This is the issue OP was having, he is a colleague.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Sequelize: updating updatedAt manually - Stack Overflow
This worked for me group.changed('updatedAt', true) await group.update({ updatedAt: new Date() }). Calling just update with updatedAt = new ...
Read more >
sequelize updatedat not updating
The save method is optimized internally to only update fields that really changed. This means that if you don't change anything and call...
Read more >
Use ->update() without updating timestamps - Laracasts
So I have a query that updates many hundreds of rows at a time, eg Model::where('something', '=', $something)->update(['status' => 'Unallocated']); ...
Read more >
Does MongoDB still update or overwrite a document if the ...
I'm working with Mongoose and the phenomena happens for both update ... we update the records using updateMany clause it will not update...
Read more >
11.2.5 Automatic Initialization and Updating for TIMESTAMP ...
TIMESTAMP or DATETIME column definitions can specify the current timestamp for both the default and auto-update values, for one but not the other,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found