-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathreaddb.js
More file actions
44 lines (37 loc) · 1.11 KB
/
readdb.js
File metadata and controls
44 lines (37 loc) · 1.11 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
if(Meteor.isServer){
Meteor.startup(function(){
if(Glasses.find().fetch().length === 0){
var dbobj = JSON.parse(Assets.getText('db.json'));
var arr = dbobj["Current Database - Table 1"];
console.log('Glasses db empty, reading in private/db.json');
var entryIsValid = function(entry){
return entry["R SPH"] && entry["R CYL"] && entry["R AXIS"]
&& entry["L SPH"] && entry["L CYL"] && entry["L AXIS"];
};
for(var i = 0; i < arr.length; i++){
var item = arr[i];
if(entryIsValid(item)){
var newItem = {
number:item["No."],
frame:item.FRAME,
lens:item.LENS,
leftRx:{
sphere:item["L SPH"],
cylinder:item["L CYL"],
axis:item["L AXIS"]
},
rightRx:{
sphere:item["R SPH"],
cylinder:item["R CYL"],
axis:item["R AXIS"]
},
}
// console.log(newItem);
Glasses.insert(newItem);
} else {
// console.log('item empty')
}
}
}
});
}