Compare commits

..

No commits in common. 'main' and 'development' have entirely different histories.

@ -6,7 +6,8 @@ Functions and Classes for handle Sqlite in [Bun](https://bun.sh/).
### getOrCreateSqlite(options = {}) ### getOrCreateSqlite(options = {})
As options the default Parameters from [Bun](https://bun.sh/docs/api/sqlite) are available. The uri of the Sqlite can be set in the .env-file, As options the default Parameters from [Bun](https://bun.sh/docs/api/sqlite) are available.
The uri of the Sqlite can be set in the .env-file,
``` ```
NANO_SQLITE_PATH="./../storage/db.sqlite" NANO_SQLITE_PATH="./../storage/db.sqlite"
@ -31,7 +32,8 @@ This functions Reads SQL-Files from a Directory and execute them in the Sqlite.
### Store ### Store
Store is a Abstract Class to extend a Class for an Single Table. Set the name of the table in super(). There is no handling of columns or validating if the exists. Store is a Abstract Class to extend a Class for an Single Table. There
are no functions to validating Columns.
``` ```
class <store-name>Store extends Store { class <store-name>Store extends Store {
@ -43,7 +45,7 @@ class <store-name>Store extends Store {
#### findOneById(id: integer) #### findOneById(id: integer)
Getting single row by id. Getting single row by Id.
#### create(data: object) #### create(data: object)
@ -51,8 +53,8 @@ Create a new row in a Table.
#### update(id: integer, data: object) #### update(id: integer, data: object)
Update single row by id. Update single row by Id.
#### remove(id: integer) #### remove(id: integer)
Remove single row by id. Remove single row by Id.

@ -1,6 +1,6 @@
{ {
"name": "@nano/sqlite", "name": "@nano/sqlite",
"version": "0.2.1", "version": "0.2.0",
"description": "Functions and Classes for handle sqlite in Bun", "description": "Functions and Classes for handle sqlite in Bun",
"repository": { "repository": {
"type": "git", "type": "git",

@ -5,7 +5,7 @@ import Store from './../src/Store.ts'
* *
* @author Björn Hase <me@herr-hase.wtf> * @author Björn Hase <me@herr-hase.wtf>
* @license http://opensource.org/licenses/MIT The MIT License * @license http://opensource.org/licenses/MIT The MIT License
* @link https://git.node001.net/nano/sqlite.git * @link https://gitea.node001.net/HerrHase/urban-filehub.git
* *
*/ */

@ -2,6 +2,6 @@ CREATE TABLE IF NOT EXISTS items (
id INTEGER PRIMARY KEY, id INTEGER PRIMARY KEY,
name TEXT, name TEXT,
description TEXT, description TEXT,
date_created_at NUMERIC, date_created_at TEXT,
date_upated_at NUMERIC date_upated_at TEXT
) )

@ -13,10 +13,20 @@ function getOrCreateSqlite(options = {}): Database {
let db let db
options = Object.assign({ // check version for merge options
uri: process.env.NANO_SQLITE_PATH, // safeIntegers only aviable in version >= 1.1.14
wal: true if (Bun.version < '1.1.14') {
}, options) options = Object.assign({
uri: process.env.NANO_SQLITE_PATH,
wal: true
}, options)
} else {
options = Object.assign({
uri: process.env.NANO_SQLITE_PATH,
wal: true,
safeIntegers: true
}, options)
}
const uri = options.uri const uri = options.uri
delete options.uri delete options.uri

Loading…
Cancel
Save