Guest User

Untitled

a guest
Sep 22nd, 2018
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  1. var mongoose = require("mongoose");
  2. var passportLocalMongoose = require("passport-local-mongoose");
  3. var userSchema = new mongoose.Schema({
  4. username: {type: String, unique: true, required: true},
  5. password: String,
  6. firstname: String,
  7. lastname: String,
  8. email: {type: String, unique: true, required: true},
  9. avatar: String,
  10. resetPasswordToken: String,
  11. resetPasswordExpires: Date
  12. });
  13.  
  14. userSchema.plugin(passportLocalMongoose);
  15.  
  16. module.exports = mongoose.model("User",
  17. userSchema)
  18. var mongoose = require("mongoose");
  19. var campgroundSchema = new mongoose.Schema({
  20. name: String,
  21. image: String,
  22. price: String,
  23. createdAt: {type: Date, default: Date.now},
  24. description : String,
  25. author: {
  26. id:{
  27. type: mongoose.Schema.Types.ObjectId,
  28. ref: "User"
  29. },
  30. username:String
  31. },
  32. comments : [
  33. {
  34. type: mongoose.Schema.Types.ObjectId,
  35. ref: "comment"
  36. }
  37. ]
  38. });
  39.  
  40. module.exports = mongoose.model("Campground", campgroundSchema);
Add Comment
Please, Sign In to add comment