store method
Implementation
@override
store(FTransactionParams transaction) async {
bool ok = false;
Future? fu;
await Future.wait(storing);
try {
fu = _db.runTx((tx) async {
for (final statement in transaction.statements) {
final result = await tx.execute(
Sql.indexed(statement.sql, substitution: '?'),
parameters: statement.parameters,
);
if (statement.sql.toLowerCase().startsWith('insert')) {
// Very basic last insert id handling, adjust as needed.
if (result.isNotEmpty && result.first.isNotEmpty) {
if (result.first.first is int) {
//_lastInsertId = result.first.first as int;
}
}
}
}
});
storing.add(fu);
await fu;
ok = true;
} catch (e) {
print('Error executing transaction: $e');
print(transaction.statements
.map((st) => '${st.parameters}\n${st.sql}')
.join('\n'));
ok = false;
}
storing.remove(fu);
return ok;
}