updatedAt not updating on save
See original GitHub issueIn 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:
- Created 8 years ago
- Comments:6 (3 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@gcatto
instance.changed('updatedAt', true)
will mark theupdatedAt
column as dirty so it will be updatedSorry 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 setmodel.nonExistantField = 'lol';
thenmodel.save()
, this would change themodel.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.