Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- export type UserModel = mongoose.Document & {
- name: string;
- username: string;
- email: string;
- password: string;
- profile: Schema.Types.ObjectId; // If I leave this property with this type, in case I populate a typescript query it would give me an error.
- };
- export const UserSchema = new Schema({
- name: {
- type: String,
- required: true
- },
- username: {
- type: String,
- required: true,
- unique: true
- },
- email: {
- type: String,
- unique: true,
- required: true
- },
- password: {
- type: String,
- required: true
- },
- profile: {
- type: Schema.Types.ObjectId,
- ref: "Profile"
- }
- });
- export default model<UserModel>("User", UserSchema);
Add Comment
Please, Sign In to add comment