import { Connection } from "../deps.ts" ; import { dso } from "./dso.ts" ; import { BaseModel } from "./model.ts" ; export class Transaction { constructor ( private _conn ) { } getModel < T extends BaseModel > ( Model ) { const model = new Model ( this . _conn ) ; return model ; } static async transaction < T > ( processor ) { return ( await dso . client . transaction ( async ( conn ) => { const trans = new Transaction ( conn ) ; return await processor ( trans ) ; } ) ) as T ; } }