无法跟踪使用sequelize-paper-trail进行版本更改的用户

时间:2018-11-08 06:20:32

标签: node.js

即使在sequelize-paper-trail的init选项中传递了usermodel之后,我也无法跟踪用户ID。下面是模型代码:

var options = {
  User: 'user',
};
var PaperTrail = require('sequelize-paper-trail').init(sequelize, options);
PaperTrail.defineModels({});
module.exports = (sequelize, DataTypes) => {
  const Post = sequelize.define('post', {
    name: DataTypes.STRING
  }, {});
  Post.Revisions = Post.hasPaperTrail();
  Post.associate = function(models) {
    // associations can be defined here
  };
  return Post;
};

在控制器中,我这样写:

post_update = await Post.update({name: "helllo world again"},{user_id: 1})

0 个答案:

没有答案