-
Notifications
You must be signed in to change notification settings - Fork 0
/
models.coffee
64 lines (54 loc) · 1.53 KB
/
models.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
mongoose = require 'mongoose'
supergoose = require 'supergoose'
UserSchema = new mongoose.Schema
name: String
email: String
picture: String
twitterId: String
UserSchema.plugin supergoose
CheckinSchema = new mongoose.Schema
journey:
type: mongoose.Schema.ObjectId
ref: 'Journey'
user:
type: mongoose.Schema.ObjectId
ref: 'User'
location:
type: mongoose.Schema.ObjectId
ref: 'Location'
JourneySchema = new mongoose.Schema
name: String
time: Date
users: [{type: mongoose.Schema.ObjectId, ref: 'User'}]
trainId: String
location: [Number, Number]
scheduleId: String
terminated: Boolean
route:
type: mongoose.Schema.ObjectId
ref: 'Route'
JourneySchema.index
location: '2d'
LocationSchema = new mongoose.Schema
name: String
location:
lon: Number
lat: Number
LocationSchema.index
location: '2d'
RouteSchema = new mongoose.Schema
start:
type: mongoose.Schema.ObjectId
ref: 'Location'
destination:
type: mongoose.Schema.ObjectId
ref: 'Location'
module.exports.user = mongoose.model 'User', UserSchema
module.exports.checkin = mongoose.model 'Checkin', CheckinSchema
module.exports.journey = mongoose.model 'Journey', JourneySchema
module.exports.location = mongoose.model 'Location', LocationSchema
module.exports.route = mongoose.model 'Route', RouteSchema
# typical queries:
# "show me all the other people checking in on this journey train right now"
# "show me all the other people who regularly check in on this route train right now"
# "show me all the "