Overview
TheRecordRepository 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.The record object to create
Resolves when the record is successfully created
findAll
Retrieves all non-deleted records from the database.Array of all active (non-deleted) records. The
isDeleted field is converted from numeric (0/1) to boolean.isDeleted field from integer to boolean.
update
Updates an existing record in the database.The record object with updated values. The
id field is used to identify which record to update.Resolves when the record is successfully updated
createdAt and isDeleted fields are not updated by this method.
softDelete
Marks a record as deleted without removing it from the database.The unique identifier of the record to soft delete
Resolves when the record is successfully marked as deleted
findAll() results but remain in the database for potential recovery or audit purposes.
Usage Example
Database Schema
The repository interacts with therecords table with the following structure:
| Column | Type | Constraints |
|---|---|---|
| id | TEXT | PRIMARY KEY |
| title | TEXT | NOT NULL |
| subtitle | TEXT | NULLABLE |
| metadata | TEXT | NULLABLE |
| type | TEXT | NOT NULL |
| userId | TEXT | NULLABLE |
| createdAt | TEXT | NOT NULL |
| updatedAt | TEXT | NOT NULL |
| isDeleted | INTEGER | NOT NULL (0 or 1) |