sequelize:如何向关联形成的主键添加一列?

sequelize: how to add one more column to primary key formed by association?

我有 3 table

class(身份证,姓名)

学生(id,姓名)

出勤率(classid, studentid, date, present)

我需要跟踪学生在特定日期 class 的出勤情况。

我必须使用 sequelize 创建架构。 现在问题是当我写类似

的东西时

class.belongsToMany(学生,{through:attendance})

student.belongsToMany(class,{through:attendance})

考勤table中的主键就是(classid,studentid).

我想包括日期列以及主键的一部分。 我怎样才能做到这一点?

我建议在模型中创建模型出勤率(classid、studentid、date、present)并在此处定义主键,如此处文档所述: https://sequelize.org/master/manual/model-basics.html

只需添加 primaryKey: true 选项到您想要作为主键的特定列。