-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfloorplan.js
More file actions
108 lines (82 loc) · 2.24 KB
/
floorplan.js
File metadata and controls
108 lines (82 loc) · 2.24 KB
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
const mongoose = require("mongoose");
const User = require("./user");
const Beacon = require("./beacon");
const ContentArea = require('./contentarea');
const BeaconPlanSchema = mongoose.model('Beacon').schema;
const ContentAreaSchema = mongoose.model('ContentArea').schema;
const FloorPlanSchema = module.exports = mongoose.Schema({
name : {
type : String,
default : "Unnamed"
},
filename : {
type: String,
required : true
},
uploadedBy:
{
type: mongoose.Schema.Types.ObjectId,
ref : User
},
size : String,
mimeType: String,
path: String,
beacons: [BeaconPlanSchema],
areas: [ContentAreaSchema],
created : {
type: Date,
default: Date.now()
},
updated : {
type: Date,
default: Date.now()
}
});
// `batchSchema.path('events')` gets the mongoose `DocumentArray`
const iBeacon = FloorPlanSchema.path('beacons').discriminator('iBeacon', Beacon.iBeaconSchema);
const eddystone = FloorPlanSchema.path('beacons').discriminator('eddystone', Beacon.eddystoneSchema);
const FloorPlan = module.exports = mongoose.model('FloorPlan', FloorPlanSchema );
module.exports.newFloorPlan = function(file, userID) {
let d = Date.now();
return new FloorPlan({
filename: file.filename,
created : d,
updated: d,
uploadedBy: userID,
size: file.size,
mimeType: file.mimetype,
path: file.path
});
};
module.exports.newIbeacon = function(model) {
let d = Date.now();
return new iBeacon({
uuid: model.uuid,
major: model.major,
minor: model.minor,
ref: model.ref,
txPower: model.txPower,
created: d,
updated: d,
map : {
x : model.map.x,
y : model.map.y
}
});
};
module.exports.newEddystoneBeacon = function(model) {
let d = Date.now();
return new eddystone({
nameSpaceId: model.nameSpaceId,
instanceId: model.instanceId,
frameType: "UID",
ref: model.ref,
txPower: model.txPower,
created: d,
updated: d,
map : {
x : model.map.x,
y : model.map.y
}
});
};