Can `update()` return `[0]` when the row exists?
See original GitHub issueFor some reason calling Model.update(values, { where: ... })
returns [0]
as if the updated row wasn’t found but at the same time Model.findOne({ where: ... })
returns the row and it is found.
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (1 by maintainers)
Top Results From Across the Web
mySQL UPDATE query returns "0 rows affected"
If the such value already exists, mysql won't change it and will therefore return "0 rows affected". So be sure to also check...
Read more >How to check if WHERE = value does not exist and make it ...
Another method: SELECT lineId FROM table_name WHERE lineId = 80 UNION ALL SELECT lineId FROM table_name WHERE lineId = 0 AND NOT EXISTS...
Read more >UPDATE-if-exists, INSERT-if-not-exists (aka UPSERT) data ...
This filters the source table to only return one row for each CUSTOMER_ID. This enables the MERGE to work. De-duplicate the source rows...
Read more >How to INSERT If Row Does Not Exist (UPSERT) in MySQL
Using INSERT ... ON DUPLICATE KEY UPDATE is non-destructive, in that it will only ever issue INSERT or UPDATE statements, but never DELETE...
Read more >13.2.15.6 Subqueries with EXISTS or NOT EXISTS
If a subquery returns any rows at all, EXISTS subquery is TRUE , and NOT ... In MySQL 8.0.19 and later, you can...
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
Was the row actually changed?
I am trying to update the totalLikes but getting [0]; await communityService.updateTotalLikes({ totalLikes }, { where: { id: communityId } });
communityService.updateTotalLikes = (data, query) => { return communityModel.update(data, query); };