Multi-Valued Reference Properties

Let’s learn how to implement multi-valued reference properties.

Introduction

A unidirectional non-functional association is either one-to-many or many-to-many. In both cases, such an association is represented or implemented with the help of a multi-valued reference property.

In this chapter, we’ll learn to:

  1. Derive a JS class model from an OO class model with multi-valued reference properties that represent unidirectional non-functional associations.
  2. Code the JS class model in the form of JavaScript model classes.
  3. Write the view and controller code based on the model code

Implement multi-valued reference properties

A multi-valued reference property, such as the property Book::authors, allows us to store a collection of references to objects of some type, like Author objects. When we create a new object of the type Book, the constructor function needs a parameter to provide a suitable value for this property. We can allow this value to be either a collection of internal object references or of ID references, as shown in the following example:

Get hands-on with 1200+ tech skills courses.