Skip to main content

Overview

The RecordRepository class handles all database operations for Record entities. It provides methods for creating, reading, updating, and soft-deleting records in the SQLite database. Location: src/infraestructure/repositories/RecordRepository.ts

Methods

create

Creates a new record in the database.
Record
required
The record object to create
Promise<void>
Resolves when the record is successfully created
Database Interaction:

findAll

Retrieves all non-deleted records from the database.
Promise<Record[]>
Array of all active (non-deleted) records. The isDeleted field is converted from numeric (0/1) to boolean.
Database Interaction:
Note: This method automatically filters out soft-deleted records and converts the isDeleted field from integer to boolean.

update

Updates an existing record in the database.
Record
required
The record object with updated values. The id field is used to identify which record to update.
Promise<void>
Resolves when the record is successfully updated
Database Interaction:
Note: The createdAt and isDeleted fields are not updated by this method.

softDelete

Marks a record as deleted without removing it from the database.
string
required
The unique identifier of the record to soft delete
Promise<void>
Resolves when the record is successfully marked as deleted
Database Interaction:
Note: Soft-deleted records are excluded from findAll() results but remain in the database for potential recovery or audit purposes.

Usage Example

Database Schema

The repository interacts with the records table with the following structure: