node.js - how to update records in association though sequelize in node js? -


we trying update records in association though sequelize updating records of model on fired or direct model no associated model affected query .

any pathway perform

return db.product.findbyid( 75759,{                 include: [                     {                         model: db.productdescription                     }                 ]})             .then(product => {                 var rahulpro = {};                 object.assign(rahulpro,product);                 // console.log(rahulpro.product_description.description);                 rahulpro.name = "44444";                 rahulpro.product_description.datavalues.description = "rahul";                 product.updateattributes(rahulpro);               }); 

what expect happen?

we want update data of description model

what happening?

nothing changed database of description

database version: mysql 5.7 sequelize version: 4.8.3

i've had similar issue using sequelize. after hours of looking it, i've seen there no great way handle data attached through tables.

for you're trying do, you'll have perform 2 queries, find product instance product table, , query product_description table description.product_id === product.id.

then write changes description instance, product instance.

this shortcoming of orm's in project, , more complex queries started using raw sequel because gave ability things this.


Comments

Popular posts from this blog

neo4j - finding mutual friends in a cypher statement starting with three or more persons -

php - How to remove letter in front of the word laravel -

minify - Minimizing css files -