qcobjects-admin-lib-db-sqlite3
Advanced tools
Comparing version
@@ -34,2 +34,3 @@ /* eslint-disable @typescript-eslint/no-var-requires */ | ||
const sqlite3_1 = require("sqlite3"); | ||
const node_fs_1 = require("node:fs"); | ||
class SQLite3Container { | ||
@@ -297,3 +298,7 @@ constructor({ pipe, id, containerFields }) { | ||
try { | ||
const db = new sqlite3_1.Database(node_path_1.default.resolve(`./${databaseName}`), sqlite3_1.OPEN_READWRITE, (err) => { | ||
const databasePath = node_path_1.default.resolve(`./${databaseName}`); | ||
if (!(0, node_fs_1.existsSync)(databasePath)) { | ||
(0, node_fs_1.writeFileSync)(databasePath, ""); | ||
} | ||
const db = new sqlite3_1.Database(databasePath, sqlite3_1.OPEN_READWRITE, (err) => { | ||
if (err) { | ||
@@ -300,0 +305,0 @@ throw new Error(`[sqlite3][database][createIfNotExists] Error creating database: ${err}`); |
{ | ||
"name": "qcobjects-admin-lib-db-sqlite3", | ||
"version": "0.0.23", | ||
"version": "0.0.24", | ||
"description": "QCObjects Admin Lib to work with SQLite3", | ||
@@ -5,0 +5,0 @@ "main": "public/js/index.cjs", |
@@ -30,2 +30,3 @@ /* eslint-disable @typescript-eslint/no-var-requires */ | ||
import { Database, OPEN_READWRITE } from "sqlite3"; | ||
import { existsSync, writeFileSync } from "node:fs"; | ||
@@ -343,3 +344,7 @@ class SQLite3Container { | ||
try { | ||
const db = new Database(path.resolve(`./${databaseName}`), OPEN_READWRITE, (err:any) => { | ||
const databasePath = path.resolve(`./${databaseName}`); | ||
if (!existsSync(databasePath)){ | ||
writeFileSync(databasePath, ""); | ||
} | ||
const db = new Database(databasePath, OPEN_READWRITE, (err:any) => { | ||
if (err) { | ||
@@ -346,0 +351,0 @@ throw new Error(`[sqlite3][database][createIfNotExists] Error creating database: ${err}`); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
134920
0.32%2707
0.37%