Created
November 22, 2024 01:11
-
-
Save theRedeemer997/a0178691a82f5f51ec47e41720605704 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- User -- | |
//import the mongoose package | |
const mongoose = require('mongoose'); | |
//get the Schema from mongoose | |
const { Schema } = mongoose; | |
//Define the schema for user | |
const userSchema = new Schema({ | |
EmailAddress: { | |
type: String, | |
required: [true, 'EmailAddress is required'], | |
unique: true, | |
trim: true, | |
match: [/.+\@.+\..+/, 'Please fill a valid email address'], | |
maxlength: 60, | |
}, | |
FirstName: { | |
type: String, | |
required: [true, 'FirstName is required'], | |
trim: true, | |
maxLength: 60, | |
}, | |
LastName: { | |
type: String, | |
required: [true, 'LastName is required'], | |
trim: true, | |
maxLength: 60, | |
}, | |
Password: { | |
type: String, | |
}, | |
BookedEvents: [ | |
{ | |
EventId: { | |
type: Schema.Types.ObjectId, | |
ref: 'approvedevents', // Reference to the approvedevents schema | |
}, | |
EventName: { | |
type: String, | |
}, | |
Tickets: { | |
type: String, | |
}, | |
FinalPrice: { | |
type: String, | |
}, | |
}, | |
], | |
SubmittedRatings: [ | |
{ | |
RatingId: { | |
type: Schema.Types.ObjectId, | |
ref: 'rating', // Reference to the rating schema | |
}, | |
EventName: { | |
type: String, | |
}, | |
Rating: { | |
type: Number, | |
required: true, | |
}, | |
Feedback: { | |
type: String, | |
maxlength: 500, | |
}, | |
Date: { | |
type: Date, | |
default: Date.now, | |
}, | |
}, | |
], | |
}); | |
module.exports = mongoose.model('user', userSchema); | |
-- ApprovedEvents -- | |
//import the mongoose package | |
const mongoose = require('mongoose'); | |
//get the Schema from mongoose | |
const { Schema } = mongoose; | |
//Define the schema for user | |
const approvedEventsSchema = new Schema({ | |
OrganizerName: String, | |
OrganizerEmail: String, | |
EventName: String, | |
SlotsAvailable: String, | |
Price: String, | |
Description: String, | |
Address: String, | |
ImageUrl: String, | |
FileName: String, | |
Ratings: [ | |
{ | |
RatingId: { | |
type: Schema.Types.ObjectId, | |
ref: 'rating', // Reference to the rating schema | |
}, | |
EventName: { | |
type: String, | |
}, | |
Rating: { | |
type: Number, | |
required: true, | |
}, | |
Feedback: { | |
type: String, | |
maxlength: 500, | |
}, | |
Date: { | |
type: Date, | |
default: Date.now, | |
}, | |
}, | |
], | |
}); | |
module.exports = mongoose.model('approvedevents', approvedEventsSchema); | |
-- created events --- | |
//import the mongoose package | |
const mongoose = require('mongoose'); | |
//get the Schema from mongoose | |
const { Schema } = mongoose; | |
//Define the schema for user | |
const createdEventsSchema = new Schema({ | |
OrganizerName: { | |
type: String, | |
required: [true, 'Organizer Name is required'], | |
trim: true, | |
maxLength: 60, | |
}, | |
OrganizerEmail: { | |
type: String, | |
required: [true, 'Organizer Email is required'], | |
trim: true, | |
maxLength: 60, | |
}, | |
EventName: { | |
type: String, | |
required: [true, 'Event Name is required'], | |
trim: true, | |
maxLength: 60, | |
}, | |
SlotsAvailable: { | |
type: String, | |
required: [true, 'Slots Available is required'], | |
trim: true, | |
maxLength: 20, | |
}, | |
Price: { | |
type: String, | |
required: [true, 'Event Price is required'], | |
trim: true, | |
maxLength: 20, | |
}, | |
Description: { | |
type: String, | |
required: [true, 'Event Description is required'], | |
trim: true, | |
minLength: [ | |
300, | |
'The Event Description cannot be less than 300 charaters', | |
], | |
maxLength: [ | |
600, | |
'The Event Description cannot be more than 600 charaters', | |
], | |
}, | |
Address: { | |
type: String, | |
required: [true, 'Address is required'], | |
trim: true, | |
maxLength: 300, | |
}, | |
ImageUrl: String, | |
FileName: String, | |
}); | |
module.exports = mongoose.model('createdevents', createdEventsSchema); | |
-- rejected events -- | |
//import the mongoose package | |
const mongoose = require('mongoose'); | |
//get the Schema from mongoose | |
const { Schema } = mongoose; | |
//Define the schema for user | |
const rejectedEventsSchema = new Schema({ | |
OrganizerName: String, | |
EventName: String, | |
SlotsAvailable: String, | |
Price: String, | |
Description: String, | |
Address: String, | |
ImageUrl: String, | |
FileName: String, | |
}); | |
module.exports = mongoose.model('rejectedEvents', rejectedEventsSchema); | |
-- ratings -- | |
//import the mongoose package | |
const mongoose = require('mongoose'); | |
//get the Schema from mongoose | |
const { Schema } = mongoose; | |
//Define the schema for user | |
const ratingsSchema = new Schema({ | |
UserId: { | |
type: Schema.Types.ObjectId, | |
ref: 'user', // Reference to the user schema | |
required: true, | |
}, | |
EventId: { | |
type: Schema.Types.ObjectId, | |
ref: 'approvedevents', // Reference to the approvedevents schema | |
required: true, | |
}, | |
Rating: { | |
type: Number, | |
required: true, | |
min: 1, | |
max: 5, | |
}, | |
Feedback: { | |
type: String, | |
maxlength: 500, | |
}, | |
Date: { | |
type: Date, | |
default: Date.now, | |
}, | |
}); | |
module.exports = mongoose.model('ratings', ratingsSchema); | |
-- organizer -- | |
//import the mongoose package | |
const mongoose = require('mongoose'); | |
//get the Schema from mongoose | |
const { Schema } = mongoose; | |
//Define the schema for user | |
const organizerSchema = new Schema({ | |
EmailAddress: { | |
type: String, | |
required: [true, 'EmailAddress is required'], | |
unique: true, | |
trim: true, | |
match: [/.+\@.+\..+/, 'Please fill a valid email address'], | |
maxlength: 60, | |
}, | |
FirstName: { | |
type: String, | |
required: [true, 'FirstName is required'], | |
trim: true, | |
maxLength: 60, | |
}, | |
LastName: { | |
type: String, | |
required: [true, 'LastName is required'], | |
trim: true, | |
maxLength: 60, | |
}, | |
Password: { | |
type: String, | |
}, | |
OrganizerName: { | |
type: String, | |
required: [true, 'Organizer Name is required'], | |
trim: true, | |
maxLength: 60, | |
}, | |
}); | |
module.exports = mongoose.model('organizers', organizerSchema); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment