@orieljs/database 0.1.0-alpha.12 → 0.1.0-alpha.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +8 -4
- package/dist/index.js.map +1 -1
- package/package.json +15 -7
package/dist/index.js
CHANGED
|
@@ -82,6 +82,7 @@ var LogicError = class extends DatabaseError {
|
|
|
82
82
|
var isBun = () => typeof globalThis.Bun !== "undefined";
|
|
83
83
|
|
|
84
84
|
// Connectors/SqliteDatabase.ts
|
|
85
|
+
import { importOptional } from "@orieljs/support";
|
|
85
86
|
var BunSqliteDatabase = class {
|
|
86
87
|
constructor(database) {
|
|
87
88
|
this.database = database;
|
|
@@ -108,13 +109,16 @@ async function openSqlite(filename) {
|
|
|
108
109
|
/* @vite-ignore */
|
|
109
110
|
specifier
|
|
110
111
|
);
|
|
111
|
-
|
|
112
|
+
const database = new Database2(filename);
|
|
113
|
+
database.prepare("PRAGMA busy_timeout = 5000").run();
|
|
114
|
+
return new BunSqliteDatabase(database);
|
|
112
115
|
}
|
|
113
|
-
const { default: Database } = await import("better-sqlite3");
|
|
116
|
+
const { default: Database } = await importOptional("better-sqlite3", "The sqlite connection", () => import("better-sqlite3"));
|
|
114
117
|
return new Database(filename);
|
|
115
118
|
}
|
|
116
119
|
|
|
117
120
|
// Connectors/dialect.ts
|
|
121
|
+
import { importOptional as importOptional2 } from "@orieljs/support";
|
|
118
122
|
import { CompiledQuery, MysqlDialect, PostgresDialect, SqliteDialect } from "kysely";
|
|
119
123
|
var PG_INT8 = 20;
|
|
120
124
|
var PG_DATE = 1082;
|
|
@@ -173,7 +177,7 @@ function createDialect(config) {
|
|
|
173
177
|
case "pgsql":
|
|
174
178
|
return new PostgresDialect({
|
|
175
179
|
pool: async () => {
|
|
176
|
-
const { default: pg } = await import("pg");
|
|
180
|
+
const { default: pg } = await importOptional2("pg", "The pgsql connection", () => import("pg"));
|
|
177
181
|
return new pg.Pool({
|
|
178
182
|
connectionString: config.url,
|
|
179
183
|
host: config.host,
|
|
@@ -201,7 +205,7 @@ function createDialect(config) {
|
|
|
201
205
|
case "mysql":
|
|
202
206
|
return new MysqlDialect({
|
|
203
207
|
pool: async () => {
|
|
204
|
-
const { createPool } = await import("mysql2");
|
|
208
|
+
const { createPool } = await importOptional2("mysql2", "The mysql connection", () => import("mysql2"));
|
|
205
209
|
return createPool(mysqlPoolOptions(config));
|
|
206
210
|
}
|
|
207
211
|
});
|