ToMany<EntityT> constructor

ToMany<EntityT>(
  1. {List<EntityT>? items}
)

Create a ToMany relationship.

Normally, you don't assign items in the constructor but rather use this class as a lazy-loaded/saved list. The option to assign in the constructor is useful to initialize objects from an external source, e.g. from JSON. Setting the items in the constructor bypasses the lazy loading, ignoring any relations that are currently stored in the DB for the source object.

Implementation

ToMany({List<EntityT>? items}) {
  if (items != null) {
    __items = items;
    items.forEach(_track);
  }
}