A like package of dbdjs.db with better-sqlite3 wrapper.
npm install dbdjs.db-sql
fetchAll to all (README.md).
database compatibility.
js
const Package = require("dbdjs.db-sql")
const db = new Package.Database("database.sql", { timeout: 5000 })
`
API
- new Package.Database(filename: string, [Interfaces.Options]): Database - Initializing Synchronous class Database
- new Package.PromisedDatabase(filename: string, [Interfaces.Options]): Database - Initializing Promised version of class Database
- Database.set(table: string, key: string, value: any): Boolean - Creating/Updating the value of a created/existing data
- Database.get(table: string, key: string): Interfaces.Data | null - Return a data with matching key from the Database
- Database.delete(table:string, key: string): Boolean - Remove a data with matching key from the Database
- Database.all(table: string): [Interfaces.AllSQLData[]](#interfaces) - Returns an Array of data in the Table
- Database.getTables(): [Interfaces.TableInformation[]](#interfaces) - Returns an Array of Information about Tables from the Database
- Database.clearTable(table: string): none - Removes the entire data of the Table
- Database.clearDatabase(): Boolean - Removes the entire table from the Database with it's contents
- Database.deleteTable(table: string): none - Remove table from the database
###### Note: Promised version will return a promise which can be handled using Promises API / Await Asynchronous.
Interfaces
$3
- readonly?: boolean - open the database connection in readonly mode (default: false).
- fileMustExist?: boolean - if the database does not exist, an Error will be thrown instead of creating a new file. This option does not affect in-memory or readonly database connections (default: false).
- timeout?: number - the number of milliseconds to wait when executing queries on a locked database, before throwing a SQLITE_BUSY error (default: 5000).
- verbose?: function | null - provide a function that gets called with every SQL string executed by the database connection (default: null`).