Added Measurements input
This commit is contained in:
parent
ba17d57987
commit
98a86ca6a8
12 changed files with 337 additions and 10 deletions
32
imports/api/measureLogEntry.js
Normal file
32
imports/api/measureLogEntry.js
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
import { Meteor } from 'meteor/meteor';
|
||||
import { Mongo } from 'meteor/mongo';
|
||||
import { check } from 'meteor/check';
|
||||
|
||||
export const MeasureLogEntry = new Mongo.Collection('measureLogEntry');
|
||||
|
||||
MeasureLogEntry.allow({
|
||||
insert: function(userId, doc){
|
||||
// if use id exists, allow insert
|
||||
return !!userId;
|
||||
},
|
||||
});
|
||||
|
||||
Meteor.methods({
|
||||
async 'add.measureLog' (measureName, measure, units) {
|
||||
check(measureName, String);
|
||||
check(measure, Number);
|
||||
check(units, String);
|
||||
|
||||
if (!this.userId) {
|
||||
throw new Meteor.Error('You are not allowed to add measurement log entries. Make sure you are logged in with valid user credentials.');
|
||||
}
|
||||
|
||||
return MeasureLogEntry.insertAsync({
|
||||
measureName: measureName,
|
||||
measure: measure,
|
||||
measureUnits: units,
|
||||
addedBy: this.userId,
|
||||
addedOn: new Date(),
|
||||
});
|
||||
},
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue