Updates for async and await - still

This commit is contained in:
Brian McGonagill 2025-07-22 13:50:49 -05:00
parent febb36d75f
commit 706c5dc3ef
18 changed files with 220 additions and 233 deletions

View file

@ -12,20 +12,20 @@ Recipes.allow({
});
Meteor.methods({
'add.recipe' (recipeName) {
async 'add.recipe' (recipeName) {
check(recipeName, String);
if (!this.userId) {
throw new Meteor.Error('You are not allowed to add recipes. Make sure you are logged in with valid user credentials.');
}
return Recipes.insertAsync({
return await Recipes.insertAsync({
recipeName: recipeName,
addedBy: this.userId,
addedOn: new Date(),
});
},
'edit.recipe' (recipeId, recipeName) {
async 'edit.recipe' (recipeId, recipeName) {
check(recipeId, String);
check(recipeName, String);
@ -33,7 +33,7 @@ Meteor.methods({
throw new Meteor.Error('You are not allowed to add recipes. Make sure you are logged in with valid user credentials.');
}
return Recipes.updateAsync({ _id: recipeId }, {
return await Recipes.updateAsync({ _id: recipeId }, {
$set: {
recipeName: recipeName,
updatedOn: new Date(),
@ -41,13 +41,13 @@ Meteor.methods({
}
});
},
'delete.recipe' (recipeId) {
async 'delete.recipe' (recipeId) {
check(recipeId, String);
if (!this.userId) {
throw new Meteor.Error('You are not allowed to delete recipes. Make sure you are logged in with valid user credentials.');
}
return Recipes.removeAsync({ _id: recipeId });
return await Recipes.removeAsync({ _id: recipeId });
}
});