-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodels.js
39 lines (34 loc) · 960 Bytes
/
models.js
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
var mongoose = require('mongoose'),
Schema = mongoose.Schema;
if(process.env.MONGO_URL) {
config.mongo.url = process.env.MONGO_URL;
} else {
config = require("./config");
}
var ClientSchema = new Schema ({
name: String,
ip: String,
headphones: String,
token: String
});
var ConferenceSchema = new Schema ({
name: String,
location: String,
description: String,
speaker: {type: Schema.Types.ObjectId, ref: 'Client'},
attending: Number,
questions: [{type: Schema.Types.ObjectId, ref: 'Post'}]
});
var PostSchema = new Schema ({
question: String,
client: {type: Schema.Types.ObjectId, ref: 'Client'},
upvotes: Number,
downvotes: Number,
comments: [{type: Schema.Types.ObjectId, ref: 'Post'}]
});
mongoose.model('Client', ClientSchema);
mongoose.model('Conference', ConferenceSchema);
mongoose.model('Post', PostSchema);
var Client = mongoose.model('Client');
var Conference = mongoose.model('Conference');
var Post = mongoose.model('Post');