Can anyone provide guidance on how to implement the PATCH method for manipulating an array within another array?
ItemClass:
export class ItemClass {
constructor(public person: string, public name: string, public quantity: number, public price: number){}
}
MenuModel:
import { ItemClass } from './item.model';
export class MenuModel {
id: number;
name: string;
items: ItemClass[];
constructor( id: number, name: string, items: ItemClass[]){
this.id = id;
this.name = name;
this.items = items;
}
}
I am working on a menu component and service. I am in need of a patch method that can both add and remove elements from the ItemClass[] array inside the MenuModel.
The API method outlined as follows :
@PATCH
@Path("/add/{menuId}")
public void removeMenuItem(
@PathParam("menuId") final int menuId,
final Item item) { // 'Item' refers to the Request Body
final List<Item> items = this.menuRepository.get(menuId).getItems();
items.add(item);
}
(source: )