简体   繁体   English

为什么在原始查询更新中未定义续集元数据?

[英]Why is sequelize metata undefined on raw query update?

I am using sequelize to run a raw MSSQL update query. 我正在使用sequelize运行原始MSSQL更新查询。 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. 如果我使用普通的select语句,则效果很好。

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() . 但是.spread(([results, metadata]) =>不起作用。请参见spread()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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