$db
Updated on Aug 19, 2025 2 minutes to readThe Db Plugin provides methods for working with database transactions.
Methods
Method | Description |
---|---|
transaction | Executes a function within a database transaction. |
Methods Details
transaction()
• Type
(
callback: () => void,
errorHandler?: (error: Error) => void
) => boolean
• Details
Expects a callback function containing database operations to execute as a transaction,
and an optional error handler function that receives an Error object if the transaction fails.
Returns true
if the transaction completed successfully, otherwise false
.
• Example
const success = E8App.$db.transaction(
() => {
// Perform database operations here
// E.g., insert, update, delete records
},
(error) => {
// Handle any transaction errors
// error contains the Error object
}
);
// success → true if all operations succeeded, false if rolled back