-
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathsql-connection.ts
More file actions
17 lines (16 loc) · 867 Bytes
/
Copy pathsql-connection.ts
File metadata and controls
17 lines (16 loc) · 867 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import type { SQLValue, SQLRow, SQLResult, SQLBatchOperation, IsolationLevel } from './definitions';
/**
* Common interface for SQL database connections.
* Implemented by NativeSQLConnection (HTTP protocol) and WebSQLConnection (direct plugin calls).
*/
export interface SQLConnection {
getDatabaseName(): string;
execute(statement: string, params?: SQLValue[]): Promise<SQLResult>;
executeBatch(operations: SQLBatchOperation[]): Promise<SQLResult[]>;
beginTransaction(isolationLevel?: IsolationLevel): Promise<void>;
commit(): Promise<void>;
rollback(): Promise<void>;
transaction<T>(callback: (conn: SQLConnection) => Promise<T>, isolationLevel?: IsolationLevel): Promise<T>;
query(statement: string, params?: SQLValue[]): Promise<SQLRow[]>;
run(statement: string, params?: SQLValue[]): Promise<{ rowsAffected: number; insertId?: number }>;
}