Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat(core): creates data models of core services #44

Merged
merged 2 commits into from
Mar 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added audio.mp3
Binary file not shown.
Binary file added audio.wav
Binary file not shown.
15 changes: 15 additions & 0 deletions core/src/constants/match-status.enum.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
enum MatchStatusEnum {
SCHEDULED = 'scheduled',
LIVE = 'live',
COMPLETED = 'completed',
INTERRUPTED = 'interrupted',
}

export const MatchStatusEnumList = [
MatchStatusEnum.COMPLETED,
MatchStatusEnum.INTERRUPTED,
MatchStatusEnum.LIVE,
MatchStatusEnum.INTERRUPTED,
];

export default MatchStatusEnum;
35 changes: 35 additions & 0 deletions core/src/models/admin.model.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// admin-model.ts - A mongoose model
//
// See http://mongoosejs.com/docs/models.html
// for more of what you can do here.
import { boolean } from 'yargs';
import RolesEnum, { RolesEnumList } from '../constants/roles.enum';
import { Application } from '../declarations';
import mongoose, { Model, Mongoose } from 'mongoose';

export default function (app: Application): Model<any> {
const modelName = 'admin';
const mongooseClient: Mongoose = app.get('mongooseClient');
const { Schema } = mongooseClient;
const schema = new Schema({
role: {
type: Number,
enum: RolesEnumList,
default: RolesEnum.ADMIN,
},
player: {
type: mongoose.Schema.Types.ObjectId,
ref: 'player'
},
// TODO isPlayer (Needed?) , expiry ??
}, {
timestamps: true
});

// This is necessary to avoid model compilation errors in watch mode
// see https://mongoosejs.com/docs/api/connection.html#connection_Connection-deleteModel
if (mongooseClient.modelNames().includes(modelName)) {
(mongooseClient as any).deleteModel(modelName);
}
return mongooseClient.model<any>(modelName, schema);
}
38 changes: 36 additions & 2 deletions core/src/models/match.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,49 @@
//
// See http://mongoosejs.com/docs/models.html
// for more of what you can do here.
import MatchStatusEnum, { MatchStatusEnumList } from '../constants/match-status.enum';
import { Application } from '../declarations';
import { Model, Mongoose } from 'mongoose';
import mongoose, { Model, Mongoose } from 'mongoose';

export default function (app: Application): Model<any> {
const modelName = 'match';
const mongooseClient: Mongoose = app.get('mongooseClient');
const { Schema } = mongooseClient;
const schema = new Schema({
text: { type: String, required: true }
team1: {
type: mongoose.Schema.Types.ObjectId,
ref: 'team',
},
team2: {
type: mongoose.Schema.Types.ObjectId,
ref: 'team',
},
squad1: {
type: mongoose.Schema.Types.ObjectId,
ref: 'squad',
required: true,
},
squad2: {
type: mongoose.Schema.Types.ObjectId,
ref: 'squad',
required: true,
},
assignedAdmin: {
type: mongoose.Schema.Types.ObjectId,
ref: 'admin',
required: true,
},
venue: {
type: String,
},
date: {
type: Date,
},
status: {
type: String,
enum: MatchStatusEnumList,
default: MatchStatusEnum.SCHEDULED,
}
}, {
timestamps: true
});
Expand Down
46 changes: 44 additions & 2 deletions core/src/models/platform-super-admin.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,57 @@
//
// See http://mongoosejs.com/docs/models.html
// for more of what you can do here.
import RolesEnum, { RolesEnumList } from '../constants/roles.enum';
import { Application } from '../declarations';
import { Model, Mongoose } from 'mongoose';
import mongoose, { Model, Mongoose } from 'mongoose';

export default function (app: Application): Model<any> {
const modelName = 'platformSuperAdmin';
const mongooseClient: Mongoose = app.get('mongooseClient');
const { Schema } = mongooseClient;
const schema = new Schema({
text: { type: String, required: true }
firstName: {
type: String,
required: true
},
lastName: {
type: String,
required: true
},
email: {
type: String,
required: true,
index: true,
},
password: {
type: String,
required: true
},
role: {
type: String,
required: true,
enum: RolesEnumList,
default: RolesEnum.PLATFORM_SUPER_ADMIN
},
contactNo: {
type: String
},
socials: [
{
type: Object
}
],
// deleted: {
// type: Boolean,
// default: false,
// index: true,
// },
// deletedBy: {
// type: mongoose.Schema.Types.ObjectId,
// },
// deletedAt: {
// type: Date
// },
}, {
timestamps: true
});
Expand Down
9 changes: 7 additions & 2 deletions core/src/models/player.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export default function (app: Application): Model<any> {
email: {
type: String,
required: true,
index: true,
},
password: {
type: String,
Expand All @@ -39,16 +40,19 @@ export default function (app: Application): Model<any> {
type: String,
required: true,
enum: SportEnumList,
index: true,
},
branch: {
type: String,
required: true,
enum: BranchEnumList
enum: BranchEnumList,
index: true,
},
year: {
type: Number,
required: true,
enum: [1, 2, 3, 4],
index: true,
},
contactNo: {
type: String
Expand All @@ -60,7 +64,8 @@ export default function (app: Application): Model<any> {
],
deleted: {
type: Boolean,
default: false
default: false,
index: true,
},
deletedBy: {
type: ObjectId,
Expand Down
33 changes: 31 additions & 2 deletions core/src/models/squad-player.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,43 @@
// See http://mongoosejs.com/docs/models.html
// for more of what you can do here.
import { Application } from '../declarations';
import { Model, Mongoose } from 'mongoose';
import mongoose, { Model, Mongoose } from 'mongoose';

export default function (app: Application): Model<any> {
const modelName = 'squadPlayer';
const mongooseClient: Mongoose = app.get('mongooseClient');
const { Schema } = mongooseClient;
const schema = new Schema({
text: { type: String, required: true }
player: {
type: mongoose.Schema.Types.ObjectId,
ref: 'player',
required: true,
},
Squad: {
type: mongoose.Schema.Types.ObjectId,
ref: 'squad',
required: true,
},
createdBy: {
type: mongoose.Schema.Types.ObjectId,
ref: 'platformSuperAdmin',
required: true,
},
deleted: {
type: Boolean,
default: false,
index: true,
},
description: {
type: String,
},
deletedBy: {
type: mongoose.Schema.Types.ObjectId,
ref: 'platformSuperAdmin'
},
deletedAt: {
type: Date
},
}, {
timestamps: true
});
Expand Down
46 changes: 44 additions & 2 deletions core/src/models/squad.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,57 @@
//
// See http://mongoosejs.com/docs/models.html
// for more of what you can do here.
import { BranchEnumList } from '../constants/branch.enum';
import { SportEnumList } from '../constants/sport.enum';
import { Application } from '../declarations';
import { Model, Mongoose } from 'mongoose';
import mongoose, { Model, Mongoose } from 'mongoose';

export default function (app: Application): Model<any> {
const modelName = 'squad';
const mongooseClient: Mongoose = app.get('mongooseClient');
const { Schema } = mongooseClient;
const schema = new Schema({
text: { type: String, required: true }
name: {
type: String,
required: true,
},
branch: {
type: String,
required: true,
enum: BranchEnumList,
index: true,
},
sport: {
type: String,
required: true,
enum: SportEnumList,
index: true,
},
createdBy: {
type: mongoose.Schema.Types.ObjectId,
ref: 'platformSuperAdmin',
required: true,
},
socials: [
{
type: String,
}
],
description: {
type: String,
},
deleted: {
type: Boolean,
default: false
},
deletedBy: {
type: mongoose.Schema.Types.ObjectId,
ref: 'player'
},
deletedAt: {
type: Date
},

}, {
timestamps: true
});
Expand Down
31 changes: 29 additions & 2 deletions core/src/models/team-player.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,41 @@
// See http://mongoosejs.com/docs/models.html
// for more of what you can do here.
import { Application } from '../declarations';
import { Model, Mongoose } from 'mongoose';
import mongoose, { Model, Mongoose } from 'mongoose';

export default function (app: Application): Model<any> {
const modelName = 'teamPlayer';
const mongooseClient: Mongoose = app.get('mongooseClient');
const { Schema } = mongooseClient;
const schema = new Schema({
text: { type: String, required: true }
team:{
type:mongoose.Schema.Types.ObjectId,
ref:'team',
required:true,
},
squad:{
type:mongoose.Schema.Types.ObjectId,
ref:'squad',
required:true,
},
position:{
type:String,
},
createdBy: {
type: mongoose.Schema.Types.ObjectId,
required: true,
},
deleted: {
type: Boolean,
default: false,
index: true,
},
deletedBy: {
type: mongoose.Schema.Types.ObjectId,
},
deletedAt: {
type: Date
},
}, {
timestamps: true
});
Expand Down
Loading
Loading