Add a PostgreSQL-specific getRecordForUpdate helper that appends FOR
UPDATE to the generated SELECT statement so callers can lock a row
inside an explicit transaction.
generateProcsForModels now always emits a direct-connection
get<RecordName>ForUpdate proc that accepts db_postgres.DbConn. There is
intentionally no dbType overload for this API, because reacquiring a
connection via withConnection would defeat the lock's transactional
scope.
The source docs and README now document the new helper and show the
intended usage pattern inside inTransaction:
db.inTransaction:
var item = conn.getTodoItemForUpdate(todoId)
item.priority += 1
discard conn.updateTodoItem(item)
- Nim 2.x has moved the DB connectors outside the standard library to
the `db_connector` package.
- Refactor the pooling implementation and macro expectations to use the
`withConnection` name instead of `withConn`. This change allows a
caller to use a [waterpark](https://github.com/guzba/waterpark) pool
instance instead of the builtin pool instance. Waterpark provides
better support for multi-threaded environments. The builtin pooling
mechanism may be deprecated in favor of waterpark in the future.
- Add the `getModelIfItExists` generated proc to the list of standard
procs we generate. This is a flavour of `getModel` that returns an
`Option` instead of raising an exception when there is no model for
the given id.
- Change `PaginationParams#orderBy` to accept a `seq[string]` to allow
for sorting on multiple fields.