-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
node_modules |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import { Model, DataTypes, Sequelize } from 'sequelize'; | ||
import User from './user.model'; // Import the User model (adjust the import path as needed) | ||
import Message from './message.model'; // Import the Message model (adjust the import path as needed) | ||
|
||
interface AttachmentsModelAttributes { | ||
file_Url: string; | ||
file_Name: string; | ||
message_id: number; | ||
creator_id: number; | ||
} | ||
|
||
interface AttachmentsModelCreationAttributes extends AttachmentsModelAttributes {} | ||
|
||
class Attachments extends Model<AttachmentsModelAttributes, AttachmentsModelCreationAttributes> { | ||
public file_Url!: string; | ||
public file_Name!: string; | ||
public message_id!: number; | ||
public creator_id!: number; | ||
|
||
// Define associations and other methods as needed | ||
|
||
public static associate(models: any): void { | ||
Attachments.belongsTo(models.User, { | ||
foreignKey: 'creator_id', | ||
as: 'user', | ||
}); | ||
|
||
Attachments.belongsTo(models.Message, { | ||
foreignKey: 'message_id', | ||
as: 'message', | ||
}); | ||
} | ||
} | ||
|
||
export function initAttachmentsModel(sequelize: Sequelize): void { | ||
Attachments.init( | ||
{ | ||
file_Url: DataTypes.STRING, | ||
file_Name: DataTypes.STRING, | ||
message_id: { | ||
type: DataTypes.INTEGER, | ||
allowNull: false, | ||
references: { | ||
model: Message, | ||
key: 'id', | ||
}, | ||
}, | ||
creator_id: { | ||
type: DataTypes.INTEGER, | ||
allowNull: false, | ||
references: { | ||
model: User, | ||
key: 'id', | ||
}, | ||
}, | ||
}, | ||
{ | ||
sequelize, | ||
modelName: 'Attachments', | ||
} | ||
); | ||
} | ||
|
||
export default Attachments; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import { Model, DataTypes, Sequelize } from 'sequelize'; | ||
import User from './user.model'; // Import the User model (adjust the import path as needed) | ||
|
||
interface GroupsModelAttributes { | ||
group_Name: string; | ||
creator_id: number; | ||
} | ||
|
||
interface GroupsModelCreationAttributes extends GroupsModelAttributes {} | ||
|
||
class Groups extends Model<GroupsModelAttributes, GroupsModelCreationAttributes> { | ||
public group_Name!: string; | ||
public creator_id!: number; | ||
|
||
// Define associations and other methods as needed | ||
|
||
public static associate(models: any): void { | ||
Groups.hasMany(models.Message, { | ||
foreignKey: 'group_id', | ||
as: 'messages', | ||
}); | ||
|
||
Groups.belongsTo(models.User, { | ||
foreignKey: 'creator_id', | ||
as: 'user', | ||
}); | ||
} | ||
} | ||
|
||
export function initGroupsModel(sequelize: Sequelize): void { | ||
Groups.init( | ||
{ | ||
group_Name: DataTypes.STRING, | ||
creator_id: { | ||
type: DataTypes.INTEGER, | ||
allowNull: false, | ||
references: { | ||
model: User, | ||
key: 'id', | ||
}, | ||
}, | ||
}, | ||
{ | ||
sequelize, | ||
modelName: 'Groups', | ||
} | ||
); | ||
} | ||
|
||
export default Groups; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import { Model, DataTypes, Sequelize } from 'sequelize'; | ||
import Group from './group.model'; // Import the Groups model (adjust the import path as needed) | ||
import User from './user.model'; // Import the User model (adjust the import path as needed) | ||
|
||
interface GroupParticipantsModelAttributes { | ||
group_id: number; | ||
user_id: number; | ||
} | ||
|
||
interface GroupParticipantsModelCreationAttributes extends GroupParticipantsModelAttributes {} | ||
|
||
class GroupParticipants extends Model<GroupParticipantsModelAttributes, GroupParticipantsModelCreationAttributes> { | ||
public group_id!: number; | ||
public user_id!: number; | ||
|
||
// Define associations and other methods as needed | ||
|
||
public static associate(models: any): void { | ||
GroupParticipants.belongsTo(models.Groups, { | ||
foreignKey: 'group_id', | ||
as: 'groups', | ||
}); | ||
|
||
GroupParticipants.belongsTo(models.User, { | ||
foreignKey: 'user_id', | ||
as: 'user', | ||
}); | ||
} | ||
} | ||
|
||
export function initGroupParticipantsModel(sequelize: Sequelize): void { | ||
GroupParticipants.init( | ||
{ | ||
group_id: { | ||
type: DataTypes.INTEGER, | ||
allowNull: false, | ||
references: { | ||
model: Group, | ||
key: 'id', | ||
}, | ||
}, | ||
user_id: { | ||
type: DataTypes.INTEGER, | ||
allowNull: false, | ||
references: { | ||
model: User, | ||
key: 'id', | ||
}, | ||
}, | ||
}, | ||
{ | ||
sequelize, | ||
modelName: 'Group_participants', | ||
} | ||
); | ||
} | ||
|
||
export default GroupParticipants; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
import { Model, DataTypes, Sequelize } from 'sequelize'; | ||
import User from './user.model'; // Import the User model (adjust the import path as needed) | ||
import Groups from './group.model'; // Import the Groups model (adjust the import path as needed) | ||
|
||
interface MessageModelAttributes { | ||
text: string; | ||
sender_id: number; | ||
reciever_id: number; | ||
group_id: number; | ||
} | ||
|
||
interface MessageModelCreationAttributes extends MessageModelAttributes {} | ||
|
||
class Message extends Model<MessageModelAttributes, MessageModelCreationAttributes> { | ||
public text!: string; | ||
public sender_id!: number; | ||
public reciever_id!: number; | ||
public group_id!: number; | ||
|
||
// Define associations and other methods as needed | ||
|
||
public static associate(models: any): void { | ||
Message.belongsTo(models.User, { | ||
foreignKey: 'sender_id', | ||
as: 'user', | ||
}); | ||
|
||
Message.hasMany(models.Attachments, { | ||
foreignKey: 'message_id', | ||
as: 'attachments', | ||
}); | ||
|
||
Message.belongsTo(models.Groups, { | ||
foreignKey: 'group_id', | ||
as: 'groups', | ||
}); | ||
} | ||
} | ||
|
||
export function initMessageModel(sequelize: Sequelize): void { | ||
Message.init( | ||
{ | ||
text: DataTypes.STRING, | ||
sender_id: { | ||
type: DataTypes.INTEGER, | ||
allowNull: false, | ||
references: { | ||
model: User, | ||
key: 'id', | ||
}, | ||
}, | ||
reciever_id: { | ||
type: DataTypes.INTEGER, | ||
allowNull: false, | ||
}, | ||
group_id: { | ||
type: DataTypes.INTEGER, | ||
allowNull: false, | ||
references: { | ||
model: Groups, | ||
key: 'id', | ||
}, | ||
}, | ||
}, | ||
{ | ||
sequelize, | ||
modelName: 'Message', | ||
} | ||
); | ||
} | ||
|
||
export default Message; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import { Model, DataTypes, Sequelize } from 'sequelize'; | ||
|
||
interface UserModelAttributes { | ||
userName: string; | ||
fullName: string; | ||
email: string; | ||
password: string; | ||
} | ||
|
||
interface UserModelCreationAttributes extends UserModelAttributes { | ||
// Add any optional attributes here | ||
} | ||
|
||
class User extends Model<UserModelAttributes, UserModelCreationAttributes> { | ||
public userName!: string; | ||
public fullName!: string; | ||
public email!: string; | ||
public password!: string; | ||
|
||
public static associate(models: any): void { | ||
User.hasMany(models.Message, { | ||
foreignKey: 'sender_id', | ||
as: 'messages', | ||
}); | ||
|
||
User.hasMany(models.Groups, { | ||
foreignKey: 'creator_id', | ||
as: 'groups', | ||
}); | ||
|
||
User.hasMany(models.Attachments, { | ||
foreignKey: 'creator_id', | ||
as: 'attachments', | ||
}); | ||
|
||
User.hasMany(models.Group_participants, { | ||
foreignKey: 'user_id', | ||
as: 'group_participants', | ||
}); | ||
} | ||
} | ||
|
||
export function initUserModel(sequelize: Sequelize): void { | ||
User.init( | ||
{ | ||
userName: DataTypes.STRING, | ||
fullName: DataTypes.STRING, | ||
email: DataTypes.STRING, | ||
password: DataTypes.STRING, | ||
}, | ||
{ | ||
sequelize, | ||
modelName: 'User', | ||
} | ||
); | ||
} | ||
|
||
export default User; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.