Initial commit
This commit is contained in:
parent
9ed5089508
commit
78e0e82449
16 changed files with 317 additions and 15 deletions
37
imports/api/workoutLog.js
Normal file
37
imports/api/workoutLog.js
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
import { Meteor } from 'meteor/meteor';
|
||||
import { Mongo } from 'meteor/mongo';
|
||||
import { check } from 'meteor/check';
|
||||
|
||||
export const WorkoutLog = new Mongo.Collection('workoutLog');
|
||||
|
||||
WorkoutLog.allow({
|
||||
insert: function(userId, doc){
|
||||
// if use id exists, allow insert
|
||||
return !!userId;
|
||||
},
|
||||
});
|
||||
|
||||
Meteor.methods({
|
||||
async 'add.log' (routineId, exerciseName, exerciseType, measure, measureUnits) {
|
||||
check(routineId, String);
|
||||
check(exerciseName, String);
|
||||
check(exerciseType, String);
|
||||
check(measure, String);
|
||||
check(measureUnits, String);
|
||||
|
||||
if (!this.userId) {
|
||||
throw new Meteor.Error('You are not allowed to add routines. Make sure you are logged in with valid user credentials.');
|
||||
}
|
||||
|
||||
return await WorkoutLog.insertAsync({
|
||||
routineId: routineId,
|
||||
exerciseName: exerciseName,
|
||||
exerciseType: exerciseType,
|
||||
measure: measure,
|
||||
measureUnits: measureUnits,
|
||||
addedBy: this.userId,
|
||||
addedOn: new Date(),
|
||||
exerciseActive: true,
|
||||
});
|
||||
},
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue