在续集中更新错误

时间:2015-07-16 20:37:42

标签: mysql sequelize.js

这是什么错误?

Unhandled rejection SequelizeDatabaseError: ER_EMPTY_QUERY: Query was empty
    at Query.formatError (node_modules/sequelize/lib/dialects/mysql/query.js:159:14)
    at Query._callback (node_modules/sequelize/lib/dialects/mysql/query.js:35:21)
    at Query.Sequence.end (node_modules/mysql/lib/protocol/sequences/Sequence.js:96:24)
    at Query.ErrorPacket (node_modules/mysql/lib/protocol/sequences/Query.js:94:8)
    at Protocol._parsePacket (node_modules/mysql/lib/protocol/Protocol.js:274:23)
    at Parser.write (node_modules/mysql/lib/protocol/Parser.js:77:12)
    at Protocol.write (node_modules/mysql/lib/protocol/Protocol.js:39:16)
    at Socket.<anonymous> (node_modules/mysql/lib/Connection.js:96:28)
    at Socket.emit (events.js:107:17)
    at readableAddChunk (_stream_readable.js:163:16)
    at Socket.Readable.push (_stream_readable.js:126:10)
    at TCP.onread (net.js:538:20)

我尝试使用以下代码更新实体:

db.Account.update({
                    'post_id': data.id
                }, {
                  where: { id: account.id }
                })
                .spread(account => {

                  next();
                });

但它不起作用。有什么想法吗?

1 个答案:

答案 0 :(得分:16)

我遇到的同样问题经过大量调试后发现了这个愚蠢的错误。我的原因是在mysql中添加了一个而忘了将其添加到代表同一个表的 sequelize model 中,所以对于你的情况也建议你只需要仔细检查一下post_id出现在帐户续集模型中。