-
Notifications
You must be signed in to change notification settings - Fork 0
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
Mongoose user types #12
base: master
Are you sure you want to change the base?
Conversation
@@ -36,6 +64,11 @@ UserSchema.methods.isValidPassword = async function ( | |||
return compare; | |||
}; | |||
|
|||
const User = mongoose.model<User, UserModel>("user", UserSchema); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you need this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we moved it up
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i would just move it down after the discriminators, up to you
// schema for reviewer | ||
}, options)); | ||
|
||
const RecommenderSchema = User.discriminator('Recommender', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
theres no role called recommender, its only counselor lol so you can remove this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bro idk all the mans keep shouting out random user types i was confused 😂
@@ -18,7 +19,34 @@ const UserSchema = new Schema<User, UserModel>({ | |||
type: String, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should just be multiple booleans like user.student=true or false like you had earlier
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -3,6 +3,7 @@ import bcrypt from "bcrypt"; | |||
import { User } from "../types"; | |||
|
|||
const Schema = mongoose.Schema; | |||
const options = { discriminatorKey: 'userType' }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would just change to type since userType is just repeating info
@@ -36,6 +64,11 @@ UserSchema.methods.isValidPassword = async function ( | |||
return compare; | |||
}; | |||
|
|||
const User = mongoose.model<User, UserModel>("user", UserSchema); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i would just move it down after the discriminators, up to you
Rishab help! -alex & stella
are we discriminating properly