Flarum (v1.8.10)
    Preparing search index...

    The Model class represents a local data resource. It provides methods to persist changes via the API.

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    content: () => any = ...
    data: ModelData = {}

    The resource object from the API.

    exists: boolean = false

    Whether or not the resource exists on the server.

    freshness: Date = ...

    The time at which the model's data was last updated. Watching the value of this property is a fast way to retain/cache a subtree if data hasn't changed.

    store: Store

    The data store that this resource should be persisted to.

    Methods

    • Generate a function which returns the value of the given has-many relationship.

      Type Parameters

      Parameters

      • name: string

      Returns () => false | (M | undefined)[]

      false if no information about the relationship exists; an array if it does, containing models if they have been loaded, and undefined for those that have not.

    • Generate a function which returns the value of the given has-one relationship.

      Type Parameters

      Parameters

      • name: string

      Returns () => false | M

      false if no information about the relationship exists; undefined if the relationship exists but the model has not been loaded; or the model if it has been loaded.

    • Generate a function which returns the value of the given has-one relationship.

      Type Parameters

      Parameters

      • name: string

      Returns () => false | M | null

      false if no information about the relationship exists; undefined if the relationship exists but the model has not been loaded; or the model if it has been loaded.