Saxonberg Server API
    Preparing search index...

    PersistenceManager - Singleton for MongoDB operations.

    Index

    Methods

    • Connect to MongoDB.

      Parameters

      • uri: string

        MongoDB connection URI (from env var MONGODB_URI)

      • dbName: string = 'saxonberg'

        Database name (default: 'saxonberg')

      Returns Promise<void>

    • Delete a document by MongoDB _id.

      Dispatches through any registered around-delete hooks for this collection. The terminal next performs the MongoDB delete.

      Parameters

      • collectionName: string

        Collection name

      • id: string

        MongoDB _id (string or ObjectId)

      Returns Promise<void>

    • Find documents matching a query.

      Parameters

      • collectionName: string

        Collection name

      • query: Record<string, unknown>

        MongoDB query object

      Returns Promise<Record<string, unknown>[]>

      Array of matching documents

    • Find a document by MongoDB _id.

      Parameters

      • collectionName: string

        Collection name

      • id: string

        MongoDB _id (string or ObjectId)

      Returns Promise<Record<string, unknown> | null>

      Document or null if not found

    • Load and register hooks from a manifest YAML file.

      Each entry clones the named template via StuffApi.clone(), narrows with MixinApi.isAroundSaveHook / isAroundDeleteHook, and registers the resulting hook against the named (collection, operation) slot.

      Fails loudly on missing template, malformed YAML, or a template whose cloned object doesn't compose the required hook capability.

      Parameters

      • OptionalyamlPath: string

        Optional override; defaults to <src>/mud/obj/hooks/hooks.yaml.

      Returns Promise<void>

    • Register an around-save or around-delete hook against a (collection, operation) slot.

      Multiple hooks may register against the same slot — they execute in registration order, each receiving next to invoke the rest of the chain (terminating in the actual MongoDB write).

      Today this is privileged only by convention (CODEOWNERS on the manifest file). When the call security framework lands it becomes formally privileged.

      Parameters

      Returns void

    • Register an around-save or around-delete hook against a (collection, operation) slot.

      Multiple hooks may register against the same slot — they execute in registration order, each receiving next to invoke the rest of the chain (terminating in the actual MongoDB write).

      Today this is privileged only by convention (CODEOWNERS on the manifest file). When the call security framework lands it becomes formally privileged.

      Parameters

      Returns void

    • Save a document (insert or update). If document has _id, updates it; otherwise inserts new document.

      Dispatches through any registered around-save hooks for this collection. Hooks may transform the doc, short-circuit, or wrap the operation. The terminal next performs the MongoDB upsert.

      Parameters

      • collectionName: string

        Collection name

      • document: Record<string, unknown>

        Document to save

      Returns Promise<string>

      MongoDB _id (as string)