<columnName>: { type: Sequelize.<type>, allowNull: <true|false>, unique: <true|false>, references: { model: <TableName> }, // This is the plural table name that the column references.}
Many to Many between Student and Lesson through StudentLessons table
student.js
constcolumnMapping= { through:'StudentLesson',// This is the model name referencing the join table. otherKey:'lessonId', foreignKey:'studentId' }Student.belongsToMany(models.Lesson, columnMapping);
lesson.js
constcolumnMapping= { through:'StudentLesson',// This is the model name referencing the join table. otherKey:'studentId', foreignKey:'lessonId' }Lesson.belongsToMany(models.Student, columnMapping);
constOp=Sequelize.Op[Op.and]: [{a:5}, {b:6}] // (a = 5) AND (b = 6)[Op.or]: [{a:5}, {a:6}] // (a = 5 OR a = 6)[Op.gt]: 6,// > 6[Op.gte]: 6,// >= 6[Op.lt]: 10,// < 10[Op.lte]: 10,// <= 10[Op.ne]: 20,// != 20[Op.eq]: 3,// = 3[Op.is]: null// IS NULL[Op.not]: true,// IS NOT TRUE[Op.between]: [6,10],// BETWEEN 6 AND 10[Op.notBetween]: [11,15],// NOT BETWEEN 11 AND 15[Op.in]: [1,2],// IN [1, 2][Op.notIn]: [1,2],// NOT IN [1, 2][Op.like]: '%hat',// LIKE '%hat'[Op.notLike]: '%hat'// NOT LIKE '%hat'[Op.iLike]: '%hat'// ILIKE '%hat' (case insensitive) (PG only)[Op.notILike]: '%hat'// NOT ILIKE '%hat' (PG only)[Op.startsWith]: 'hat'// LIKE 'hat%'[Op.endsWith]: 'hat'// LIKE '%hat'[Op.substring]: 'hat'// LIKE '%hat%'[Op.regexp]: '^[h|a|t]'// REGEXP/~ '^[h|a|t]' (MySQL/PG only)[Op.notRegexp]: '^[h|a|t]'// NOT REGEXP/!~ '^[h|a|t]' (MySQL/PG only)[Op.iRegexp]: '^[h|a|t]'// ~* '^[h|a|t]' (PG only)[Op.notIRegexp]: '^[h|a|t]'// !~* '^[h|a|t]' (PG only)[Op.like]: { [Op.any]: ['cat','hat']}