2024-07-28 19:42:23 -05:00
|
|
|
import { Meteor } from 'meteor/meteor';
|
|
|
|
|
import { Mongo } from 'meteor/mongo';
|
|
|
|
|
import { check } from 'meteor/check';
|
|
|
|
|
import { Products } from './products';
|
|
|
|
|
|
|
|
|
|
export const MenuProdLinks = new Mongo.Collection('menuProdLinks');
|
|
|
|
|
|
|
|
|
|
MenuProdLinks.allow({
|
|
|
|
|
insert: function(userId, doc){
|
|
|
|
|
// if use id exists, allow insert
|
|
|
|
|
return !!userId;
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
Meteor.methods({
|
2024-08-14 11:38:13 -05:00
|
|
|
'add.menuProdLinks' (menuItemId, menuItemName, prodNameArray) {
|
2024-07-28 19:42:23 -05:00
|
|
|
check(menuItemId, String);
|
2024-08-14 11:38:13 -05:00
|
|
|
check(menuItemName, String);
|
|
|
|
|
check(prodNameArray, [Object]);
|
2024-07-28 19:42:23 -05:00
|
|
|
|
|
|
|
|
if (!this.userId) {
|
|
|
|
|
throw new Meteor.Error('You are not allowed to add menu and product links. Make sure you are logged in with valid user credentials.');
|
2024-08-14 11:38:13 -05:00
|
|
|
};
|
2024-07-28 19:42:23 -05:00
|
|
|
|
2024-08-14 11:38:13 -05:00
|
|
|
MenuProdLinks.insert({
|
|
|
|
|
menuItemId: menuItemId,
|
|
|
|
|
menuItemName: menuItemName,
|
|
|
|
|
products: prodNameArray,
|
|
|
|
|
dateCreated: Date(),
|
|
|
|
|
createdBy: this.userId
|
|
|
|
|
});
|
2024-07-28 19:42:23 -05:00
|
|
|
}
|
2024-08-14 11:38:13 -05:00
|
|
|
});
|