Model Code
Let’s learn how to code the model.
We'll cover the following...
We'll cover the following...
Code the add operation
For the multi-valued reference property Book::authors, we need to code the operations addAuthor
and removeAuthor. Both operations accept one parameter, which denotes an author either by ID reference (the author ID as integer or string) or by an object reference.
The code of addAuthor is as follows:
Code the remove operation
In the removeAuthor method, the author reference is first checked and, if no constraint violation is
detected, the corresponding entry in the map this._authors is deleted:
Code the set operation
To assign an array of ID references, or a map of object references, to the property Book::authors, the method ...