Setu-TS
    Preparing search index...

    Interface IRepository<Entity, Id>

    Generic repository providing CRUD operations over an entity type.

    0.1.0

    interface IRepository<Entity, Id extends EntityKey = string> {
        count(options?: CountOptions): Promise<number>;
        create(data: Partial<Entity>): Promise<Entity>;
        delete(id: Id): Promise<boolean>;
        deleteWhere?(id: Id, where: WritePrecondition): Promise<boolean>;
        exists(id: Id): Promise<boolean>;
        findAll(options?: FindOptions): Promise<Entity[]>;
        findById(id: Id): Promise<Entity | null>;
        findOne(options?: FindOptions): Promise<Entity | null>;
        findPage(options: FindOptions): Promise<Page<Entity>>;
        update(id: Id, data: Partial<Entity>): Promise<Entity>;
        updateWhere?(
            id: Id,
            where: WritePrecondition,
            data: Partial<Entity>,
        ): Promise<Entity | null>;
    }

    Type Parameters

    • Entity

      The entity shape the repository manages

    • Id extends EntityKey = string

      Primary key type, constrained to EntityKey (scalar string/number or composite record). Defaults to string.

    Implemented by

    Index
    • Delete only while the key and every equality precondition match. Optional permanently. BaseRepository rejects before I/O if the source lacks it.

      Parameters

      • id: Id

        Primary key

      • where: WritePrecondition

        Non-empty string/number equality map on stored values

      Returns Promise<boolean>

      Whether the conditional delete applied

      For an invalid predicate or unsupported source

      0.9.0

    • Update only while the key and every equality precondition match. Optional permanently. BaseRepository rejects before I/O if the source lacks it.

      Parameters

      • id: Id

        Primary key

      • where: WritePrecondition

        Non-empty string/number equality map on stored values

      • data: Partial<Entity>

        Non-empty update payload

      Returns Promise<Entity | null>

      Updated entity, or null for a missing key or predicate mismatch

      For an invalid predicate or unsupported source

      0.9.0