Adding Log Entry
This commit is contained in:
parent
e8649038ad
commit
b5bab7b2a6
6 changed files with 230 additions and 0 deletions
50
imports/api/logEntry.js
Normal file
50
imports/api/logEntry.js
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
import { Meteor } from 'meteor/meteor';
|
||||
import { Mongo } from 'meteor/mongo';
|
||||
import { check } from 'meteor/check';
|
||||
|
||||
export const LogEntry = new Mongo.Collection('logEntry');
|
||||
|
||||
LogEntry.allow({
|
||||
insert: function(userId, doc){
|
||||
// if use id exists, allow insert
|
||||
return !!userId;
|
||||
},
|
||||
});
|
||||
|
||||
Meteor.methods({
|
||||
async 'add.logEntry' (routineId, logId, exerciseName, measName1, measure1, measUnit1, measName2, measure2, measUnit2, measName3, measure3, measUnit3) {
|
||||
check(routineId, String);
|
||||
check(logId, String);
|
||||
check(exerciseName, String);
|
||||
check(measName1, String);
|
||||
check(measure1, Number);
|
||||
check(measUnit1, String);
|
||||
check(measName2, String);
|
||||
check(measure2, Number);
|
||||
check(measUnit2, String);
|
||||
check(measName3, String);
|
||||
check(measure3, Number);
|
||||
check(measUnit3, String);
|
||||
|
||||
if (!this.userId) {
|
||||
throw new Meteor.Error('You are not allowed to add log entries. Make sure you are logged in with valid user credentials.');
|
||||
}
|
||||
|
||||
return await LogEntry.insertAsync({
|
||||
routineId: routineId,
|
||||
logId: logId,
|
||||
exerciseName: exerciseName,
|
||||
measName1: measName1,
|
||||
measure1: measure1,
|
||||
measUnit1: measUnit1,
|
||||
measName2: measName2,
|
||||
measrue2: measure2,
|
||||
measUnit2: measUnit2,
|
||||
measName3: measName3,
|
||||
measure3: measure3,
|
||||
measUnit3: measUnit3,
|
||||
addedBy: this.userId,
|
||||
addedOn: new Date()
|
||||
});
|
||||
},
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue