mirror of
https://github.com/aljazceru/turso.git
synced 2025-12-20 18:04:19 +01:00
simplify setup by emiting index.js in ESM style from napi
This commit is contained in:
@@ -34,8 +34,7 @@ function createErrorByName(name, message) {
|
||||
/**
|
||||
* Database represents a connection that can prepare and execute SQL statements.
|
||||
*/
|
||||
export class Database {
|
||||
static SqliteError = SqliteError;
|
||||
class Database {
|
||||
db: NativeDB;
|
||||
memory: boolean;
|
||||
open: boolean;
|
||||
@@ -97,7 +96,7 @@ export class Database {
|
||||
if (!this.open) {
|
||||
throw new TypeError("The database connection is not open");
|
||||
}
|
||||
|
||||
|
||||
if (!sql) {
|
||||
throw new RangeError("The supplied SQL string contains no statements");
|
||||
}
|
||||
@@ -200,7 +199,7 @@ export class Database {
|
||||
if (!this.open) {
|
||||
throw new TypeError("The database connection is not open");
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
this.db.batch(sql);
|
||||
} catch (err) {
|
||||
@@ -328,7 +327,7 @@ class Statement {
|
||||
async *iterate(...bindParameters) {
|
||||
this.stmt.reset();
|
||||
bindParams(this.stmt, bindParameters);
|
||||
|
||||
|
||||
while (true) {
|
||||
const stepResult = this.stmt.step();
|
||||
if (stepResult === STEP_IO) {
|
||||
@@ -399,3 +398,5 @@ class Statement {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export { Database, SqliteError }
|
||||
Reference in New Issue
Block a user