Added Measurements input

This commit is contained in:
Brian McGonagill 2026-02-10 16:38:44 -06:00
parent ba17d57987
commit 98a86ca6a8
12 changed files with 337 additions and 10 deletions

View 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(),
});
},
});