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

Mongoose user types #12

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Mongoose user types #12

wants to merge 2 commits into from

Conversation

stella-cai
Copy link
Contributor

Rishab help! -alex & stella
are we discriminating properly

@stella-cai stella-cai added the dont merge i warned you label Jan 18, 2021
@@ -36,6 +64,11 @@ UserSchema.methods.isValidPassword = async function (
return compare;
};

const User = mongoose.model<User, UserModel>("user", UserSchema);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you need this

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we moved it up

Copy link
Collaborator

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

backend/src/models/User.ts Outdated Show resolved Hide resolved
backend/src/models/User.ts Outdated Show resolved Hide resolved
// schema for reviewer
}, options));

const RecommenderSchema = User.discriminator('Recommender',
Copy link
Collaborator

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image
bet

Copy link
Collaborator

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,
Copy link
Collaborator

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image
don't think we need booleans can just use instanceof

Copy link
Contributor Author

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' };
Copy link
Collaborator

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);
Copy link
Collaborator

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

@stella-cai stella-cai removed the dont merge i warned you label Feb 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants