generated from hack4impact-calpoly/nextjs-app-template
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #27 from hack4impact-calpoly/sammy-create-user-sch…
…ema-in-mongodb feat: user_schema
- Loading branch information
Showing
4 changed files
with
52 additions
and
19 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 |
---|---|---|
|
@@ -26,7 +26,7 @@ yarn-error.log* | |
|
||
# local env files | ||
.env*.local | ||
/.env | ||
.env | ||
|
||
# vercel | ||
.vercel | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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 |
---|---|---|
@@ -1,9 +1,42 @@ | ||
/* | ||
Things to include in the schema | ||
user role : user or admin : String | ||
events user went to : id attached to the event : List | ||
volunteer events users went to : id's of the volunteer event : List | ||
age : Integer | ||
gender: String | ||
Acceptance Criteria | ||
Exactly as above | ||
*/ | ||
|
||
import mongoose, { Schema } from "mongoose"; | ||
|
||
//! Example user schema. Not guaranteed to work | ||
type User = { | ||
email: string; | ||
firstName: string; | ||
lastName: string; | ||
age: number; | ||
gender: number; | ||
role: ["user", "admin"]; | ||
digitalWaiver: Schema.Types.ObjectId | null; | ||
eventsAttended: [Schema.Types.ObjectId]; | ||
}; | ||
|
||
const UserSchema = new Schema({ | ||
email: { type: String, required: true, unique: true }, | ||
password: { type: String, required: true }, | ||
email: { type: String, required: true, unique: true }, | ||
firstName: { type: String, required: true }, | ||
lastName: { type: String, required: true }, | ||
age: { type: Number, required: true }, | ||
gender: { type: String, required: true }, | ||
role: { type: String, enum: ["user", "admin"], required: true }, | ||
digitalWaiver: { type: Schema.Types.ObjectId, required: false }, | ||
eventsAttended: [{ type: Schema.Types.ObjectId, ref: "Event" }], | ||
}); | ||
|
||
export default mongoose.models.User || mongoose.model("User", UserSchema); |