RequestContext
Index
Constructors
Properties
Accessors
Methods
Constructors
constructor
Parameters
map: Map<string, EntityManager<IDatabaseDriver<Connection>>>
Returns RequestContext
Properties
readonlyid
readonlymap
Accessors
em
Returns default EntityManager.
Returns undefined | EntityManager<IDatabaseDriver<Connection>>
Methods
staticcreate
Creates new RequestContext instance and runs the code inside its domain. If the handler is async, the return value needs to be awaited. Uses
AsyncLocalStorage.run()
, suitable for regular express style middlewares with anext
callback.Parameters
em: EntityManager<IDatabaseDriver<Connection>> | EntityManager<IDatabaseDriver<Connection>>[]
next: (...args: any[]) => T
options: CreateContextOptions = {}
Returns T
staticcurrentRequestContext
Returns current RequestContext (if available).
Returns undefined | RequestContext
staticenter
Creates new RequestContext instance and runs the code inside its domain. If the handler is async, the return value needs to be awaited. Uses
AsyncLocalStorage.enterWith()
, suitable for elysia style middlewares without anext
callback.Parameters
em: EntityManager<IDatabaseDriver<Connection>> | EntityManager<IDatabaseDriver<Connection>>[]
options: CreateContextOptions = {}
Returns void
staticgetEntityManager
Returns current EntityManager (if available).
Parameters
name: string = 'default'
Returns undefined | EntityManager<IDatabaseDriver<Connection>>
Uses
AsyncLocalStorage
to create async context that holds the current EM fork.