/
schema.coffee
47 lines (41 loc) · 875 Bytes
/
schema.coffee
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# Defines the schema of data
# Exports three Mongoose Model objects: Question, Round, and Quiz
mongoose = require "mongoose"
Schema = mongoose.Schema
Question = new Schema
kind:
type: String
enum: [ "text" ]
text:
type: String
required: true
answer:
type: String
required: true
value: Number
{ strict: true }
Round = new Schema
kind:
type: String
required: true
enum: ["normal", "challenge", "wager"]
title:
type: String
required: true
questions: [Question]
{ strict: true }
Quiz = new Schema
title:
type: String
required: true
unique: true
created:
type: Date
default: -> new Date()
location: String
rounds: [Round]
{ strict: true }
module.exports =
Question: mongoose.model('Question', Question)
Round: mongoose.model('Round', Round)
Quiz: mongoose.model('Quiz', Quiz)