update() breaks when sequelize configured with raw:true
See original GitHub issueAffects master, v1.4.3, etc.
A call to update()
results in a Model.findById
call:
https://github.com/feathersjs/feathers-sequelize/blob/master/src/index.js#L168
If sequelize is configured with raw: false
(the default), this returns a DAO, with a toJSON
method, which is then called several lines later:
https://github.com/feathersjs/feathers-sequelize/blob/master/src/index.js#L174
However, if sequelize is configured with raw: true
, the findById
call returns a JSON object without this method.
There are two simple fixes:
- Only call
toJSON
if it exists and is a function - pass
{raw: false}
as a second argument to thefindById
call to force the expected behaviour
Issue Analytics
- State:
- Created 6 years ago
- Comments:7 (7 by maintainers)
Top Results From Across the Web
How to use 'sequelize.sync()' without difficulties - Medium
After executing migrate command, you get database that is fully set up. $ npx sequelize db:migrate. Don't fortget to remove 'sync()' option from ......
Read more >Upgrade to v6 - Sequelize
Sequelize v6 is the next major release after v5. Below is a list of breaking changes to help you upgrade.
Read more >Manual | Sequelize - ESDoc Hosting Service
Sequelize is a promise-based Node.js ORM for Postgres, MySQL, MariaDB, ... In this tutorial you will learn to make a simple setup of...
Read more >Create or Update Sequelize - Stack Overflow
Basically I have a array of objects and a could use the BulkCreate() method. But as the Cron starts again, it doesn't solve...
Read more >sequelize update record and return value Code Example
Result is array because we have used findAll. We can use findOne as well if you want one row and update that. 9....
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 FreeTop 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
Top GitHub Comments
Makes sense. This can probably easily be fixed by changing the line you pointed out to
Ah, I see. Well at least we know it didn’t break anything else 😉
I think we should do what
patch
does and usethis.Model.update(omit(data, this.id), options)
instead of callingsave
on the model instance.