We use sequelize on node js I have resourse File. File has attribute UserId. Need: copy same files (by filesId) to user. If use sql then need do:
INSERT INTO files (name, link, userId) SELECT name, link, 5 FROM files WHERE id in (1,2,3,4,10)
But how do it on sequelize I not have any ideas... Only custom sql query.
You can use sequelize.query()
to run raw queries.
await sequelize
.query(
`INSERT INTO files (name, link, userId)
SELECT name, link, 5 FROM files WHERE id in (1,2,3,4,10)`
)
.then((r) => r)
.catch((err) => {
throw err;
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With