Using raw bulk update query with Sequelize

wal*_*loc 2 node.js sequelize.js

I would like to use this type of request with sequelize to make large number of updates in one request (for performance reasons) :

UPDATE employee
SET address = new.address,
name = new.name
from (values :updateStack) AS new(address, name, employeeId)
WHERE employee.id = new.employeeId
Run Code Online (Sandbox Code Playgroud)

Here is the value of updateStack :

[{
    address: 'France',
    name: 'Chris',
    employeeId: 21
}, {
    address: 'UK',
    name: 'Steve',
    employeeId: 42
}]
Run Code Online (Sandbox Code Playgroud)

I'm not sure how sequelize can properly parse the updateStack array. Any idea ?

This SQL query is working fine :

UPDATE employee
SET address = new.address,
name = new.name
from (values ('France', 'Chris', 21), ('UK', 'Steve', 42)) AS new(address, name, employeeId)
WHERE employee.id = new.employeeId
Run Code Online (Sandbox Code Playgroud)

Thank you and have a good day.

wal*_*loc 5

我发现了怎么做!

sequelize.query(
            `
                UPDATE employee
                SET address = new.address,
                name = new.name
                from (values ?) AS new(address, name, employeeId)
                WHERE employee.id = new.employeeId
            `,
            {
                replacements: [['France', 'Chris', 21], ['UK', 'Steve', 42]],
                type: models.models.sequelize.QueryTypes.INSERT
            }
    )
Run Code Online (Sandbox Code Playgroud)