mirror of
https://github.com/Troplo/Colubrina.git
synced 2024-11-25 20:49:12 +11:00
61 lines
1.4 KiB
JavaScript
61 lines
1.4 KiB
JavaScript
"use strict"
|
|
const { Model } = require("sequelize")
|
|
module.exports = (sequelize, DataTypes) => {
|
|
class ChatAssociation extends Model {
|
|
/**
|
|
* Helper method for defining associations.
|
|
* This method is not a part of Sequelize lifecycle.
|
|
* The `models/index` file will call this method automatically.
|
|
*/
|
|
// eslint-disable-next-line no-unused-vars
|
|
static associate(models) {
|
|
ChatAssociation.belongsTo(models.User, {
|
|
foreignKey: "userId",
|
|
as: "user"
|
|
})
|
|
ChatAssociation.belongsTo(models.Chat, {
|
|
foreignKey: "chatId",
|
|
as: "chat"
|
|
})
|
|
}
|
|
}
|
|
ChatAssociation.init(
|
|
{
|
|
chatId: {
|
|
type: DataTypes.BIGINT,
|
|
allowNull: false
|
|
},
|
|
userId: {
|
|
type: DataTypes.BIGINT,
|
|
allowNull: false
|
|
},
|
|
rank: {
|
|
type: DataTypes.ENUM(["member", "admin"]),
|
|
defaultValue: "member",
|
|
allowNull: false
|
|
},
|
|
lastRead: {
|
|
type: DataTypes.BIGINT,
|
|
defaultValue: null
|
|
},
|
|
createdAt: {
|
|
allowNull: false,
|
|
type: DataTypes.DATE
|
|
},
|
|
updatedAt: {
|
|
allowNull: false,
|
|
type: DataTypes.DATE
|
|
},
|
|
notifications: {
|
|
type: DataTypes.ENUM(["all", "none", "mentions"]),
|
|
defaultValue: "all",
|
|
allowNull: false
|
|
}
|
|
},
|
|
{
|
|
sequelize,
|
|
modelName: "ChatAssociation"
|
|
}
|
|
)
|
|
return ChatAssociation
|
|
}
|