UNPKG

@fxjs/db-driver

Version:

[![NPM version](https://img.shields.io/npm/v/@fxjs/db-driver.svg)](https://www.npmjs.org/package/@fxjs/db-driver) [![Build Status](https://travis-ci.org/fxjs-modules/db-driver.svg)](https://travis-ci.org/fxjs-modules/db-driver) [![Build status](https://

38 lines (37 loc) 1.3 kB
/// <reference types="fib-pool" /> Object.defineProperty(exports, "__esModule", { value: true }); const db = require("db"); const base_class_1 = require("./base.class"); const utils_1 = require("../utils"); class SQLiteDriver extends base_class_1.SQLDriver { constructor(conn) { super(conn); this.connection = null; } open() { return super.open(); } close() { if (this.connection) this.connection.close(); } ping() { return; } begin() { return this.connection.begin(); } commit() { return this.connection.commit(); } trans(cb) { return this.connection.trans(cb); } rollback() { return this.connection.rollback(); } getConnection() { return db.openSQLite(this.uri); } dbExists(dbname) { // return this.execute(`SELECT name FROM sqlite_master WHERE type='table' AND name='${dbname}'`).length > 0; return true; } execute(sql) { if (this.extend_config.debug_sql) { (0, utils_1.logDebugSQL)('sqlite', sql); } if (this.isPool) return this.pool(conn => conn.execute(sql)); if (!this.connection) this.open(); return this.connection.execute(sql); } } exports.default = SQLiteDriver;