其他sequelize hooks,如afterUpdate(instance, options)
提供修改模型的实例作为参数。但是,afterUpsert(created, options)
提供created
bool 值,指示操作是插入还是更新。
有没有办法配置sequelize,或者操纵afterUpsert
参数,以获得更新插入模型的实例?
最佳答案
据我所知,你不能。作为 result
的 upsert
通过 queryInterface
调用 db是返回到 afterUpsert
的内容钩子(Hook),即 boolean
值 upsert
中是否有任何新创建的记录过程。
同时,您可以使用 beforeUpsert
将值传递给 upsert
方法。不确定这是否有帮助(可能是清除缓存)
关于node.js - 如何从 afterUpsert 钩子(Hook)中获取更新后的 Sequelize 模型的实例?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60508456/