-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added model schemas for chapter and birthdayRequest
- Loading branch information
Showing
2 changed files
with
214 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,141 @@ | ||
import mongoose from 'mongoose'; | ||
|
||
const BirthdayRequestSchema = new mongoose.Schema({ | ||
chapterId: { | ||
type: mongoose.Schema.Types.ObjectId, | ||
ref: 'Chapter', | ||
required: true, | ||
}, | ||
deadlineDate: { | ||
type: Date, | ||
required: true, | ||
}, | ||
childBirthday: { | ||
type: Date, | ||
required: true, | ||
}, | ||
childAge: { | ||
type: Number, | ||
required: true, | ||
}, | ||
childName: { | ||
type: String, | ||
required: true, | ||
}, | ||
childGender: { | ||
type: String, | ||
enum: ['Boy', 'Girl'], | ||
required: true, | ||
}, | ||
childRace: { | ||
type: String, | ||
enum: [ | ||
'White', | ||
'Black or African American', | ||
'Hispanic or Latino', | ||
'Native American or American Indian', | ||
'Asian / Pacific Islander', | ||
'Not Sure', | ||
], | ||
required: true, | ||
}, | ||
childInterests: { | ||
type: String, | ||
required: true, | ||
}, | ||
childAllergies: { | ||
type: Boolean, | ||
required: true, | ||
}, | ||
allergyDetails: { | ||
type: String, | ||
required: false, | ||
}, | ||
giftSuggestions: { | ||
type: String, | ||
required: false, | ||
}, | ||
additionalInfo: { | ||
type: String, | ||
required: false, | ||
}, | ||
agencyWorkerName: { | ||
type: String, | ||
required: true, | ||
}, | ||
agencyOrganization: { | ||
type: String, | ||
required: true, | ||
}, | ||
agencyWorkerPhone: { | ||
type: String, | ||
required: true, | ||
}, | ||
agencyWorkerEmail: { | ||
type: String, | ||
required: true, | ||
match: | ||
/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/, | ||
}, | ||
isFirstReferral: { | ||
type: Boolean, | ||
required: true, | ||
}, | ||
agreeFeedback: { | ||
type: Boolean, | ||
required: true, | ||
}, | ||
requestedDate: { | ||
type: Date, | ||
required: true, | ||
default: Date.now, | ||
}, | ||
status: { | ||
type: String, | ||
enum: ['Pending', 'Approved', 'Delivered'], | ||
required: true, | ||
default: 'Pending', | ||
}, | ||
deliveryDate: { | ||
type: Date, | ||
required: false, | ||
}, | ||
}); | ||
|
||
interface IBirthdayRequest extends mongoose.Document { | ||
_id: string; | ||
chapterId: string; | ||
deadlineDate: Date; | ||
childBirthday: Date; | ||
childAge: number; | ||
childName: string; | ||
childGender: 'Boy' | 'Girl'; | ||
childRace: | ||
| 'White' | ||
| 'Black or African American' | ||
| 'Hispanic or Latino' | ||
| 'Native American or American Indian' | ||
| 'Asian / Pacific Islander' | ||
| 'Not Sure'; | ||
childInterests: string; | ||
childAllergies: boolean; | ||
allergyDetails: string; | ||
giftSuggestions: string; | ||
additionalInfo: string; | ||
agencyWorkerName: string; | ||
agencyOrganization: string; | ||
agencyWorkerPhone: string; | ||
agencyWorkerEmail: string; | ||
isFirstReferral: boolean; | ||
agreeFeedback: boolean; | ||
requestedDate: Date; | ||
status: 'Pending' | 'Approved' | 'Delivered'; | ||
deliveryDate: Date | null; | ||
} | ||
|
||
const BirthdayRequest = mongoose.model<IBirthdayRequest>( | ||
'BirthdayRequest', | ||
BirthdayRequestSchema, | ||
); | ||
|
||
export { IBirthdayRequest, BirthdayRequest }; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
import mongoose from 'mongoose'; | ||
|
||
const ChapterSchema = new mongoose.Schema({ | ||
username: { | ||
type: String, | ||
required: true, | ||
unique: true, | ||
}, | ||
location: { | ||
type: String, | ||
required: true, | ||
}, | ||
isAcceptingRequests: { | ||
type: Boolean, | ||
required: true, | ||
default: true, | ||
}, | ||
email: { | ||
type: String, | ||
required: true, | ||
unique: true, | ||
match: | ||
/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/, | ||
}, | ||
password: { | ||
type: String, | ||
required: true, | ||
}, | ||
verified: { | ||
type: Boolean, | ||
required: true, | ||
default: false, | ||
}, | ||
verificationToken: { | ||
type: String, | ||
required: false, | ||
unique: true, | ||
sparse: true, | ||
}, | ||
resetPasswordToken: { | ||
type: String, | ||
required: false, | ||
unique: true, | ||
sparse: true, | ||
}, | ||
resetPasswordTokenExpiryDate: { | ||
type: Date, | ||
required: false, | ||
}, | ||
isAdmin: { | ||
type: Boolean, | ||
required: true, | ||
default: false, | ||
}, | ||
}); | ||
|
||
interface IChapter extends mongoose.Document { | ||
_id: string; | ||
username: string; | ||
location: string; | ||
isAcceptingRequests: boolean; | ||
email: string; | ||
password: string; | ||
verified: boolean; | ||
verificationToken: string | null | undefined; | ||
resetPasswordToken: string | null | undefined; | ||
resetPasswordTokenExpiryDate: Date | null | undefined; | ||
isAdmin: boolean; | ||
} | ||
|
||
const Chapter = mongoose.model<IChapter>('Chapter', ChapterSchema); | ||
|
||
export { IChapter, Chapter }; |