@dxos/client
    Preparing search index...

    Interface Ref<T>

    Represents materialized reference to a target. This is the data type for the fields marked as ref.

    interface Ref<T> {
        "[RefTypeId]": { _T: T };
        get dxn(): DXN;
        get target(): undefined | T;
        encode(): EncodedReference;
        load(): Promise<T>;
        noInline(): this;
        tryLoad(): Promise<undefined | T>;
    }

    Type Parameters

    • T
    Index

    Properties

    Accessors

    Methods

    Properties

    "[RefTypeId]": { _T: T }

    Accessors

    • get dxn(): DXN

      Target object DXN.

      Returns DXN

    • get target(): undefined | T

      Returns undefined | T

      The reference target. May return undefined if the object is not loaded in the working set. Accessing this property, even if it returns undefined will trigger the object to be loaded to the working set.

      Supports signal subscriptions.

    Methods

    • Serializes the reference to a JSON object. The serialization format is compatible with the IPLD-style encoded references. When a reference has a saved target (i.e. the target or object holding the reference is not in the database), the target is included in the serialized object.

      Examples: { "/": "dxn:..." } { "/": "dxn:...", "target": { ... } }

      Returns EncodedReference

    • Returns Promise<T>

      Promise that will resolves with the target object. Will load the object from disk if it is not present in the working set.

      If the object is not available locally.

    • Do not inline the target object in the reference. Makes .target unavailable unless the reference is connected to a database context.

      When serialized with toJSON, the difference is between: { "/": "dxn:..." } and { "/": "dxn:...", "target": { ... } }

      Returns this

    • Returns Promise<undefined | T>

      Promise that will resolves with the target object or undefined if the object is not loaded locally.