Skip to content

Commit

Permalink
First commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Hadiqa11 committed Oct 2, 2023
0 parents commit 6e89ed0
Show file tree
Hide file tree
Showing 5,102 changed files with 1,274,539 additions and 0 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
64 changes: 64 additions & 0 deletions models/attachment.model.ts
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;
50 changes: 50 additions & 0 deletions models/group.model.ts
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;
58 changes: 58 additions & 0 deletions models/groupmember.model.ts
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;
Empty file added models/index.ts
Empty file.
72 changes: 72 additions & 0 deletions models/message.model.ts
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;
58 changes: 58 additions & 0 deletions models/user.model.ts
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;
1 change: 1 addition & 0 deletions node_modules/.bin/css-beautify

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions node_modules/.bin/editorconfig

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions node_modules/.bin/html-beautify

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions node_modules/.bin/js-beautify

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions node_modules/.bin/nopt

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions node_modules/.bin/resolve

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions node_modules/.bin/semver

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions node_modules/.bin/sequelize

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions node_modules/.bin/sequelize-cli

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions node_modules/.bin/tsc

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions node_modules/.bin/tsserver

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions node_modules/.bin/uuid

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 6e89ed0

Please sign in to comment.