Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface for generic CRUD operations on a repository for a specific entity.

It is assumed that all operations are asynchronous and could fail, thus returning an Either monad.

Type parameters

  • T: Entity<any>

    the entity type the repository manages

  • ID: EntityId

    the type of the id of the entity the repository manages

Hierarchy

Index

Properties

count

count: () => Promise<number>

Returns the number of entities.

returns

the number of entities.

Type declaration

    • (): Promise<number>
    • Returns Promise<number>

delete

delete: (entity: T) => Promise<void>

Deletes a given entity.

param

to delete.

Type declaration

    • (entity: T): Promise<void>
    • Parameters

      • entity: T

      Returns Promise<void>

deleteAll

deleteAll: (entities?: T[]) => Promise<void>

Deletes the given entities, or all when no arguments are provided.

param

to delete or undefined to delete all.

Type declaration

    • (entities?: T[]): Promise<void>
    • Parameters

      • Optional entities: T[]

      Returns Promise<void>

deleteById

deleteById: (id: ID) => Promise<void>

Deletes the entity with the given id.

param

of entity to delete.

Type declaration

    • (id: ID): Promise<void>
    • Parameters

      • id: ID

      Returns Promise<void>

existsById

existsById: (id: ID) => Promise<boolean>

Returns whether an entity with the given ID exists.

param

of the entity.

returns

true if an entity with the given id exists, false otherwise.

Type declaration

    • (id: ID): Promise<boolean>
    • Parameters

      • id: ID

      Returns Promise<boolean>

findAll

findAll: () => Promise<T[]>

Returns all instances of the type.

returns

all entities

Type declaration

    • (): Promise<T[]>
    • Returns Promise<T[]>

findAllById

findAllById: (ids: ID[]) => Promise<T[]>

Returns all instances of the type T with the given IDs.

If some or all ids are not found, no entities are returned for these IDs.

Note that the order of elements in the result is not guaranteed.

param

of entities to be retuned.

returns

the entities.

Type declaration

    • (ids: ID[]): Promise<T[]>
    • Parameters

      • ids: ID[]

      Returns Promise<T[]>

findById

findById: (id: ID) => Promise<T | undefined>

Retrieves an entity by its ID.

param

of the entity.

returns

the entity with the given ID or undefined if none found.

Type declaration

    • (id: ID): Promise<T | undefined>
    • Parameters

      • id: ID

      Returns Promise<T | undefined>

save

save: <S>(entity: S) => Promise<S>

Saves a given entity. Use the returned instance for further operations as the save operation might have changed the entity instance.

param

to save.

returns

the saved entity.

Type declaration

    • <S>(entity: S): Promise<S>
    • Type parameters

      • S: T

      Parameters

      • entity: S

      Returns Promise<S>

saveAll

saveAll: <S>(entities: S[]) => Promise<S[]>

Saves all given entities.

param

to save.

returns

the saved entities.

Type declaration

    • <S>(entities: S[]): Promise<S[]>
    • Type parameters

      • S: T

      Parameters

      • entities: S[]

      Returns Promise<S[]>

Legend

  • Constructor
  • Property
  • Method
  • Inherited constructor
  • Inherited property
  • Inherited method
  • Property
  • Method
  • Protected property
  • Private property
  • Static method

Generated using TypeDoc