alexa-skillz / alexa-interview-overflow

Gathering user-generated interview questions and answers for our Alexa interview skill(s). Mongo, Express, Node. (Authors: Team)
https://alexa-interview-overflow.herokuapp.com/
MIT License
2 stars 1 forks source link

Build out models. #3

Closed b-d-johnson closed 7 years ago

b-d-johnson commented 7 years ago
b-d-johnson commented 7 years ago

Some ideas:

User Schema

const userSchema = Schema({
  username: { type: String, required: true, unique: true },
  email: { type: String, required: true, unique: true },
  password: { type: String, required: true },
  findHash: { type: String, unique: true }
});

Question Schema

const questionSchema = Schema({
  question: { type: String, required: true },
  created: { type: Date, required: true, default: Date.now },
  answers: [AnswerSchema],
  userID: { type: mongoose.Schema.Types.ObjectId, required: true }
});

Answer Schema

const answerSchema = Schema({
  answer: { type: String, required: true },
  created: { type: Date, default: Date.now },
  updated: { type: Date, default: Date.now },
  votes: {type: Number, default:0},
  userID: { type: Schema.Types.ObjectId, required: true }
});

answerSchema could have methods to update and vote.