简体   繁体   中英

Why is sequelize metata undefined on raw query update?

I am using sequelize to run a raw MSSQL update query. The documentation for raw update queries states that the message for number of rows updated will be contained in the metadata. In the following function both results and metadata are undefined on update statements. It works perfectly fine if I use a normal select statement.

Documentation

The section in reference is the very first example.

Could someone help me understand what I am doing incorrectly?

var query = 'UPDATE contacts SET aolid = 1 WHERE contactid =  804748'  

connection.query(query).spread(([results, metadata]) => {
        console.log(metadata)  // will log undefined
        console.log(results) // will log undefined
      })

Either use

.then(([results, metadata]) =>

or

.spread((results, metadata) =>

but .spread(([results, metadata]) => will not work. See spread() .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM