Currently module types (e.g. MyModule) are auto-generated for DB context vars. They hold the DB connection and any cache objects.
These should be renamed as DB context types (e.g. MyDbContext), contained within a module type. This new module type will only be a starter, with a the DB var and a WebContext var (if relevant) to which users can add additional context vars:
Type changes:
MyModule DB type becomes MyDbContext
The new overall type is MyContext
# File: types/my_db_context.nim
# Auto-generated per: nexus gen models
import tables
type
MyDbContext* = object
dbConn*: DbConn
ordersCache*: Table[string, Order]
# File: types/my_context.nim
# Only the starter code is auto-generated.
# After that, add any context vars you may need.
import options
import my_db_context
type
MyContext* = object
db*: MyDbContext
web*: WebContext
# Add your own context vars here
currentOrderId*: Option[int64]
Currently module types (e.g. MyModule) are auto-generated for DB context vars. They hold the DB connection and any cache objects.
These should be renamed as DB context types (e.g. MyDbContext), contained within a module type. This new module type will only be a starter, with a the DB var and a WebContext var (if relevant) to which users can add additional context vars:
Type changes:
Calling a DB proc would then look like this: