mirror of
https://codeberg.org/andyscott/ExerciseTracker.git
synced 2024-12-21 11:43:10 -05:00
Added deleteExercise
This commit is contained in:
parent
ce1bc18721
commit
7ed98cb838
1 changed files with 24 additions and 1 deletions
|
@ -40,19 +40,42 @@ const createExercise = async (name, reps, weight, unit, date) => {
|
|||
return exercise.save();
|
||||
};
|
||||
|
||||
/**
|
||||
* Get all exercises
|
||||
*/
|
||||
const findExercises = async (filter) => {
|
||||
const query = Exercise.find(filter);
|
||||
return query.exec();
|
||||
};
|
||||
|
||||
/**
|
||||
* Get the exercise associated with a given ID
|
||||
*/
|
||||
const findExerciseById = async (_id) => {
|
||||
const query = Exercise.findById(_id);
|
||||
return query.exec();
|
||||
};
|
||||
|
||||
/**
|
||||
* Update an exercise
|
||||
*/
|
||||
const updateExercise = async (_id, update) => {
|
||||
const result = await Exercise.updateOne(_id, update);
|
||||
return result.modifiedCount;
|
||||
};
|
||||
|
||||
export { createExercise, findExerciseById, findExercises, updateExercise };
|
||||
/**
|
||||
* Delete an exercise
|
||||
*/
|
||||
const deleteExercise = async (_id) => {
|
||||
const result = await Exercise.deleteOne(_id);
|
||||
return result.deletedCount;
|
||||
};
|
||||
|
||||
export {
|
||||
createExercise,
|
||||
findExerciseById,
|
||||
findExercises,
|
||||
updateExercise,
|
||||
deleteExercise,
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue