functional-models
    Preparing search index...

    Function ModelReferenceProperty

    • A property that has a reference to another model instance. A "Foreign Key" if you will. For full functionality a ModelInstanceFetcher must be provided in the config. This property has complex functionalities.

      When a model calls "instance.get.whatever()" to get the value of a ModelReferenceProperty, it uses the model fetcher to retrieve the model. (Could be saved elsewhere, or a database). When the promise is awaited, the value returned is a ModelInstance object.

      However, when toObj() is called on that same instance, only the primary key value is returned. This is so that when you call toObj() on the main instance, the "foreign key" gets filled in.

      This is useful for a save function with an ORM.

      Type Parameters

      • T extends Readonly<{ [s: string]: any }>

      Parameters

      Returns ModelReferencePropertyInstance<
          T,
          ModelReferenceType<T, object, object>,
          object,
          object,
      >