Guest User

Untitled

a guest
Nov 1st, 2018
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. export type UserModel = mongoose.Document & {
  2. name: string;
  3. username: string;
  4. email: string;
  5. password: string;
  6. 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.
  7. };
  8.  
  9.  
  10. export const UserSchema = new Schema({
  11. name: {
  12. type: String,
  13. required: true
  14. },
  15. username: {
  16. type: String,
  17. required: true,
  18. unique: true
  19. },
  20. email: {
  21. type: String,
  22. unique: true,
  23. required: true
  24. },
  25.  
  26. password: {
  27. type: String,
  28. required: true
  29. },
  30. profile: {
  31. type: Schema.Types.ObjectId,
  32. ref: "Profile"
  33. }
  34. });
  35.  
  36. export default model<UserModel>("User", UserSchema);
Add Comment
Please, Sign In to add comment