Flarum (2.x)
    Preparing search index...

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

    interface IModelWithIconImage {
        data: ModelData;
        exists: boolean;
        freshness: Date;
        store: Store;
        apiEndpoint(): string;
        attribute<T = unknown>(attribute: string): T;
        copyData(): ModelData;
        delete(
            body?:
                | Document
                | XMLHttpRequestBodyInit
                | object & { [id: string]: any }
                | null
                | undefined,
            options?: Omit<FlarumRequestOptions<void>, "url">,
        ): Promise<void>;
        iconImageSrcset(): string | null | undefined;
        iconImageUrl(): string | null | undefined;
        id(): string | undefined;
        pushAttributes(attributes: ModelAttributes): void;
        pushData(data: ModelData | { relationships?: SaveRelationships }): this;
        rawRelationship<M extends Model<M>>(
            relationship: string,
        ): ModelIdentifier | undefined;
        rawRelationship<M extends Model[]>(
            relationship: string,
        ): ModelIdentifier[] | undefined;
        save(
            attributes: SaveAttributes,
            options?: Omit<FlarumRequestOptions<ApiPayloadSingle>, "url"> & {
                meta?: MetaInformation;
            },
        ): Promise<ApiResponseSingle<IModelWithIconImage>>;
    }

    Hierarchy (View Summary)

    • Model
      • IModelWithIconImage
    Index
    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.