withOpenDb Method

Open a database, perform an operation, then close the database.

Details:

  • if database is open, throw an error
  • open a database
  • call a function with the database opened. If it is async, await its return.
  • if function throws, abandon all changes, close database, and rethrow
  • save all changes
  • close the database

withOpenDb<T>(args: SQLiteDb.WithOpenDbArgs, operation: () => T): T

@returns value from operation

Parameter Type Description
args SQLiteDb.WithOpenDbArgs  
operation () => T  

Returns - T

value from operation

Defined in

Last Updated: 15 May, 2024