Skip to main content

Interface: IRepository<T>

Defined in: Data/Core/IRepository.ts:23

Base interface for all repository implementations.

Repositories provide a clean API for CRUD operations on specific entities, abstracting away the underlying SQL implementation.

Each repository requires an ISql provider to be injected via the constructor, following the Dependency Injection pattern.

Example implementation:

class UserRepository implements IRepository<User> {
constructor(private sql: ISql) {}

getById(id: number): User | undefined {
return this.sql.queryOne<User>('SELECT * FROM users WHERE id = ?', [id]);
}

// ... other methods
}

Extended by

Type Parameters

T

T

Methods

create()

create(entity): T

Defined in: Data/Core/IRepository.ts:36

Create a new entity

Parameters

entity

T

Entity to create

Returns

T

The created entity with ID populated


delete()

delete(id): boolean

Defined in: Data/Core/IRepository.ts:50

Delete an entity by ID

Parameters

id

number

Primary key of the entity to delete

Returns

boolean

True if deleted, false if not found


getAll()

getAll(options?): T[]

Defined in: Data/Core/IRepository.ts:57

Get all entities

Parameters

options?

RepositoryQueryOptions

Optional query options (limit, offset, ordering)

Returns

T[]

Array of all entities


getById()

getById(id): T | undefined

Defined in: Data/Core/IRepository.ts:29

Retrieve an entity by its ID

Parameters

id

number

Primary key of the entity

Returns

T | undefined

The entity, or undefined if not found


update()

update(entity): T

Defined in: Data/Core/IRepository.ts:43

Update an existing entity

Parameters

entity

T

Entity with updated values

Returns

T

The updated entity