MCPcopy Create free account
hub / github.com/Effect-TS/effect / withTransaction

Function withTransaction

packages/platform/browser/src/IndexedDbQueryBuilder.ts:1997–2014  ·  view source on GitHub ↗
(this: IndexedDbQueryBuilder<any>, options: {
    readonly tables: NonEmptyReadonlyArray<any>
    readonly mode: globalThis.IDBTransactionMode
    readonly durability?: IDBTransactionDurability
  })

Source from the content-addressed store, hash-verified

1995 },
1996 ...CommonProto,
1997 withTransaction(this: IndexedDbQueryBuilder<any>, options: {
1998 readonly tables: NonEmptyReadonlyArray<any>
1999 readonly mode: globalThis.IDBTransactionMode
2000 readonly durability?: IDBTransactionDurability
2001 }) {
2002 return (effect) =>
2003 Effect.suspend(() => {
2004 const transaction = this.database.current.transaction(options.tables, options.mode, options)
2005 return Effect.provideService(effect, IndexedDbTransaction, transaction).pipe(
2006 Effect.onExit((exit) =>
2007 exit._tag === "Success" ? awaitTransaction(transaction) : abortTransaction(transaction)
2008 )
2009 )
2010 }).pipe(
2011 // To prevent async gaps between transaction queries
2012 Effect.provideService(References.PreventSchedulerYield, true)
2013 )
2014 }
2015}
2016
2017const abortTransaction = (transaction: globalThis.IDBTransaction) =>

Callers

nothing calls this directly

Calls 4

awaitTransactionFunction · 0.85
abortTransactionFunction · 0.85
transactionMethod · 0.80
pipeMethod · 0.65

Tested by

no test coverage detected