By default, the methods execute, executeSet, and run are inherently transactional. This means each individual call is treated as a single transaction.
While this is secure and suitable for single operations triggered by UI components, it can be significantly slow when performing a large batch of commands because each command incurs the overhead of its own transaction.
On the Web platform, if you use the jeep-sqlite web component, the in-memory database is saved to the store after the execution of each method if the autosave property is enabled.
const testTransactionDefault = async (db: SQLiteDBConnection) => {
if (db !== null) {
// Each of these is its own transaction
await db.execute('DELETE FROM DemoTable');
await db.run('INSERT INTO DemoTable (name, score) VALUES (?, ?);', ['Sue', 102]);
await db.execute("INSERT INTO DemoTable (name, score) VALUES ('Andrew',415);");
const ret = await db.executeSet(setScores);
const retQuery = await db.query("SELECT * FROM Demotable;");
}
}