即使在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})