0

I would like to a bulk update in sequelize. Unfortunately it seems like sequelize does not support bulk updates I am using sequelize-typescript if that helps and using postgresql 14

My query in raw SQL looks like this

UPDATE feed_items SET tags = val.tags FROM 
(
    VALUES ('ddab8ce7-afa3-824f-7b65-edfb53a71764'::uuid,ARRAY[]::VARCHAR(255)[]), 
    ('ece9f2fc-2a09-4a95-16ce-07293b0a14d2'::uuid,ARRAY[]::VARCHAR(255)[])
) AS val(id, tags) WHERE feed_items.id = val.id

I would like to generate this query from a given array of string and array values. The tags is implemented as a string array in my table.

  1. Is there a way to generate the above query without using raw query?
  2. Or an SQL injection safe way of generating the above query?
3
  • 1
    What DBMS do you use? Commented Nov 27, 2022 at 11:30
  • @Anatoly postgres Commented Nov 27, 2022 at 11:30
  • 1
    Maybe it would be helpful to use a PostgreSQL function to generate a recordset from an array and pass the array using a named parameter with bind option Commented Nov 27, 2022 at 11:32

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.