I create an API that updates a record associated with a foreign key
-
if I just put a value to items so I want it to return remove other values that I don’t put
-
if I edit some value in items so I want it to return the value that I edited
-
if I put value over value of items so I want it to return the old value of items and the value that I put over
example: const record = {id:1,name:"abc",items:[{id:1,name:"abc",recordId:1},{id:2,name:"abcd",recordId:1}]}
const update = await dbRecord.update({id,name},{where: {id: req.params.id},include:[model:'items',id:[1,2]});
2
Answers
so it create update delete in once time.
You can use Sequelize mixins. Sequelize has special methods that uses the prefix get add set concatenated with the model name.