Saxonberg Server API
    Preparing search index...

    Base for MongoDB-backed records. NOT in the Stuff hierarchy.

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    _id?: string

    MongoDB ObjectId (undefined until saved).

    actor: string = "system"

    Durable key of the acting principal (or 'system').

    amount: number = 0

    Positive minor units moved by this leg.

    at: number = 0

    Game-time SECONDS magnitude — the world clock.

    category: PnlCategory = "other"

    The P&L line this row rolls up into.

    createdAt: Date

    Created timestamp (set on construction).

    fromAccount: string = ""

    Debited account id (or a sentinel) — indexed.

    kind: LedgerKind = "transfer"

    The transaction kind.

    locality: string | null = null

    Address-prefix scope where it happened, or null = global.

    memo: string = ""

    Free-text note.

    realAt: number = 0

    Real-time epoch MILLISECONDS — the wall clock.

    toAccount: string = ""

    Credited account id (or a sentinel) — indexed.

    txId: string = ""

    Shared id grouping the legs of one multi-leg transaction.

    updatedAt: Date

    Last updated timestamp (set on every save).

    collectionName: Collections = Collections.BankLedger

    Collection name (must be overridden in subclass).

    persistentFields: string[] = ...

    Methods

    • Load data from a MongoDB document into this object.

      Symmetric to toDocument: marshallers transform their assigned fields' raw values via fromStored before bracket-assign hits the runtime setter.

      Parameters

      • doc: Record<string, unknown>

      Returns void

    • Save this object to MongoDB. Updates updatedAt automatically.

      Pre-resolves any registered field marshallers via the async resolver before the sync toDocument walk; the sync resolver lookup inside toDocument then always hits a populated cache.

      Returns Promise<void>

    • Convert this object to a plain document for MongoDB.

      Marshallers (declared via static fieldMarshallers on a mixin or class) intercept their assigned fields: the runtime value-object value is passed through marshaller.toStored before being written into the doc. Fields without a marshaller pass through bracket-read unchanged.

      Returns Record<string, unknown>

    • Wire the marshaller-resolution seam once at boot (and in tests). Keeps Document free of a StuffApi import while still reaching the Idea-rooted marshaller instances. sync mirrors StuffApi.findByTemplatePath (returns the registered instance or undefined); async mirrors StuffApi.singleton (resolves / lazy-clones the instance, warming the cache sync then hits).

      Parameters

      • sync: SyncMarshallerResolver
      • async: AsyncMarshallerResolver

      Returns void