-
Notifications
You must be signed in to change notification settings - Fork 1
/
models.js
executable file
·84 lines (76 loc) · 2 KB
/
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
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
module.exports = function(mongoose) {
var Schema = mongoose.Schema;
//Define all the mongoose models for context types
var LocationSchema = Schema(
{
description: String,
time: Number,
loc: {
type: [Number], // [<longitude>, <latitude>]
index: '2dsphere' // create the 2d geospatial index
}
});
var PlaceSchema = Schema(
{
id: String,
name: String,
loc: LocationSchema,
type: Number,
category: String,
likelihood: Number
});
var PlacesSchema = Schema(
{
places: [PlaceSchema],
time: Number
});
var NoiseSchema = Schema(
{
soundDb: Number,
soundRms: Number,
isSilent: Boolean,
time: Number
});
var NetworkSchema = Schema(
{
isWifiConnected: Boolean,
wifiSsid: String,
mobileNetworkType: String
});
var ContextSchema = Schema(
{
location: LocationSchema,
places: PlacesSchema,
place: String,
activity: Number,
noise: NoiseSchema,
network: NetworkSchema,
weekday: Number,
time: Date,
hours: Number,
minutes: Number
});
var FileSchema = Schema(
{
uuid: String,
md5: String,
descriptiveName: String,
mimetype: String,
extension: String,
filesize: Number,
creationTimestamp: Number,
context: ContextSchema,
isPrivate: Boolean,
phoneID: String
});
var models = {
Location : mongoose.model('Location', LocationSchema),
Place : mongoose.model('Place', PlaceSchema),
Places : mongoose.model('Places', PlacesSchema),
Noise : mongoose.model('Noise', NoiseSchema),
Network : mongoose.model('Network', NetworkSchema),
Context : mongoose.model('Context', ContextSchema),
File : mongoose.model('File', FileSchema)
};
return models;
}