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

@ -15,20 +15,20 @@ Menus.allow({
});
Meteor.methods({
'add.menu' (menuName) {
async 'add.menu' (menuName) {
check(menuName, String);
if (!this.userId) {
throw new Meteor.Error('You are not allowed to add menus. Make sure you are logged in with valid user credentials.');
}
return Menus.insertAsync({
return await Menus.insertAsync({
menuName: menuName,
menuOwner: this.userId,
menuComplete: false,
});
},
'edit.menu' (menuId, menuName) {
async 'edit.menu' (menuId, menuName) {
check(menuId, String);
check(menuName, String);
@ -36,48 +36,48 @@ Meteor.methods({
throw new Meteor.Error('You are not allowed to edit menus. Make sure you are logged in with valid user credentials.');
}
return Menus.updateAsync({ _id: menuId }, {
return await Menus.updateAsync({ _id: menuId }, {
$set: {
menuName: menuName,
}
});
},
'delete.menu' (menuId) {
async 'delete.menu' (menuId) {
check(menuId, String);
if (!this.userId) {
throw new Meteor.Error('You are not allowed to delete menus. Make sure you are logged in with valid user credentials.');
}
return Menus.removeAsync({ _id: menuId });
return await Menus.removeAsync({ _id: menuId });
},
'markMenu.complete' (menuId) {
async 'markMenu.complete' (menuId) {
check(menuId, String);
if (!this.userId) {
throw new Meteor.Error('You are not allowed to mark menus complete. Make sure you are logged in with valid user credentials.');
}
return Menus.updateAsync({ _id: menuId }, {
return await Menus.updateAsync({ _id: menuId }, {
$set: {
menuComplete: true,
}
});
},
'markMenu.notComplete' (menuId) {
async 'markMenu.notComplete' (menuId) {
check(menuId, String);
if (!this.userId) {
throw new Meteor.Error('You are not allowed to mark menus not complete. Make sure you are logged in with valid user credentials.');
}
return Menus.updateAsync({ _id: menuId }, {
return await Menus.updateAsync({ _id: menuId }, {
$set: {
menuComplete: false,
}
});
},
'clean.Menus' () {
async 'clean.Menus' () {
if (!this.userId) {
throw new Meteor.Error('You are not allowed to clean up old Menus. Make sure you are logged in with valid user credentials.');
}
@ -114,10 +114,10 @@ Meteor.methods({
// finally we'll cycle through the ids and remove the items we collected up.
for (let l = 0; l < removeMenuIds.length; l++) {
Menus.removeAsync({ _id: removeMenuIds[l] });
await Menus.removeAsync({ _id: removeMenuIds[l] });
}
},
'addto.Menu' (menuId, menuItem, menuItemId, dateSrv, isLinked) {
async 'addto.Menu' (menuId, menuItem, menuItemId, dateSrv, isLinked) {
check(menuId, String);
check(menuItem, String);
check(menuItemId, String);
@ -130,7 +130,7 @@ Meteor.methods({
let serveDateActual = new Date(dateSrv);
return Menus.updateAsync({ _id: menuId }, {
return await Menus.updateAsync({ _id: menuId }, {
$addToSet: {
menuItems:
{
@ -143,7 +143,7 @@ Meteor.methods({
}
});
},
'link.inMenu' (menuItemId, isLinked) {
async 'link.inMenu' (menuItemId, isLinked) {
check(menuItemId, String);
check(isLinked, Boolean);
@ -151,13 +151,13 @@ Meteor.methods({
throw new Meteor.Error('You are not allowed to link menu items to products. Make sure you are logged in with valid user credentials.');
}
return Menus.updateAsync({ 'menuItems.menuItemId': menuItemId }, {
return await Menus.updateAsync({ 'menuItems.menuItemId': menuItemId }, {
$set: {
"menuItems.$.isLinked": isLinked
}
});
},
'delete.itemFromMenu' (itemIds) {
async 'delete.itemFromMenu' (itemIds) {
check(itemIds, String);
if (!this.userId) {
@ -167,7 +167,7 @@ Meteor.methods({
let ids = itemIds.split('_');
console.log("item ids: " + ids[0] + " and " + ids[1]);
return Menus.updateAsync({ _id: ids[0] }, {
return await Menus.updateAsync({ _id: ids[0] }, {
$pull: {
menuItems: {
menuItemId: ids[1],