From e2d7393e39a17d76ae9c365c7f38158c7ec0f9d8 Mon Sep 17 00:00:00 2001 From: kaj dijkstra Date: Sun, 4 Jan 2026 14:05:14 +0100 Subject: [PATCH] Added readme --- README.md | 86 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..5ac0c6d --- /dev/null +++ b/README.md @@ -0,0 +1,86 @@ +Below is a **concise README** that covers **both files together** as a single small project. + +--- + +# SQLite Query Builder and Database Manager + +This project provides a **lightweight SQLite database manager and SQL query builder** for Node.js, built on top of `better-sqlite3`. It offers a programmatic way to construct, execute, and synchronize SQL queries without writing raw SQL strings manually. + +## Features + +* SQLite database management using `better-sqlite3` +* Programmatic construction of `SELECT`, `INSERT`, `UPDATE`, `DELETE`, and `COUNT` queries +* Support for joins, unions, filters, grouping, ordering, limits, and offsets +* Automatic ID generation using time-based unique identifiers +* Basic schema management (table creation, column addition, column tracking) +* Optional synchronization hook for distributed or client-server setups +* No external ORM dependency + +## Architecture Overview + +* **databaseManager** + Central entry point responsible for: + + * Database connection and execution + * Schema creation and migration helpers + * Query parsing and execution routing + +* **querySQL / joinSQL** + Declarative query objects that describe: + + * Tables, columns, values + * Filters and search expressions + * Joins, unions, grouping, and ordering + +* **Query parsing layer** + Converts query objects into valid SQLite SQL statements with parameter binding. + +## Basic Usage + +### Create a table and column + +```js +import database from "./source/database.js"; + +database.createTable( "user" ); +database.addColumn( "name", "VARCHAR", "user" ); +``` + +### Insert data + +```js +import querySQL from "./source/querySQL.js"; + +var query = new querySQL(); +query.type = "insert"; +query.table = "user"; +query.setValue( "name", "john" ); + +database.query( query ); +``` + +### Select data + +```js +var query = new querySQL(); +query.type = "select"; +query.table = "user"; +query.find( "name", "john" ); + +var result = database.query( query ); +console.log( result ); +``` + +## Intended Use + +* Small to medium Node.js applications +* Embedded or local SQLite-backed tools +* Projects needing structured SQL generation without a full ORM +* Environments where raw SQL strings are undesirable + +## Notes + +* This is **not a full ORM**; it focuses on query construction and execution. +* Schema changes are tracked via an internal `tableColumns` table. +* Designed for synchronous SQLite access via `better-sqlite3`. +