In the UI code we can now exploit the inverse reference properties for more efficiently creating a list of inversely associated objects in the Retrieve/List All use case. For instance, we can more efficiently create a list of all published books for each publisher. However, we do not allow updating the set of inversely associated objects in the update object use case (e.g., updating the set of published books in the update publisher use case). Rather, such an update has to be done via updating the master objects (in our example, the books) concerned.
For showing information about published books in the Retrieve/List All publishers use case, we can
now exploit the derived inverse reference property
publishedBooks
:
const tableBodyEl = document.querySelector("section#Publisher-R > table > tbody"); tableBodyEl.innerHTML = ""; for (const key of Object.keys( Publisher.instances)) { const publisher = Publisher.instances[key]; const row = tableBodyEl.insertRow(); // create list of books published by this publisher const publBooksListEl = createListFromMap( publisher.publishedBooks, "title"); row.insertCell().textContent = publisher.name; row.insertCell().textContent = publisher.address; row.insertCell().appendChild( publBooksListEl); }