A repository implementing database interaction procs for sqlite Do NOT use this module directly ! Use genericRepository instead ! Any repository module must provide the procs read, create, list, update, delete, count, executeQuery and listAll.
Types
QueryResult = (seq[Row], seq[string])
- Source Edit
Procs
proc create[T: Model](newModel: var T; beforeCreateAction: ActionProc[T]; afterCreateAction: ActionProc[T]) {....gcsafe.}
- Inserts the newModel into the database. Executes the provided ActionProc before/after adding the model if they were provided. Source Edit
proc delete[T: Model](modelType: typedesc[T]; id: int64; beforeDeleteAction: ActionProc[T]) {....gcsafe.}
- Deletes the model of type modelType in the database with the given id. Executes the provided ActionProc before deleting the model if it was provided. Source Edit
proc executeQuery(query: string): Option[QueryResult] {. ...raises: [DbError, DbError], tags: [DbEffect, ReadEnvEffect, ReadDbEffect, WriteDbEffect], forbids: [].}
- Executes the given SQL query on the database. Note that you may only use DML SQL statements. Returns a QueryResult if the given query is a SELECT query. Source Edit
proc list[T: Model](pageIndex: int; pageSize: int; sortFields: seq[string]; sortDirection: SortDirection): seq[T]
- Reads a paginated list of models from the database. The number of models in a page is pageSize. The list of models is sorted according to the provided sortFields in the order of sortDirection. Source Edit
proc update[T: Model](updateModel: var T; beforeUpdateAction: ActionProc[T]; afterUpdateAction: ActionProc[T]) {....gcsafe.}
- Persists the updateModel into the database, overwriting any previous entry with the same id. Executes the provided ActionProc before/after updating the model if they were provided. Source Edit