e2d7393e39a17d76ae9c365c7f38158c7ec0f9d8
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, andCOUNTqueries - 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
import database from "./source/database.js";
database.createTable( "user" );
database.addColumn( "name", "VARCHAR", "user" );
Insert data
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
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
tableColumnstable. - Designed for synchronous SQLite access via
better-sqlite3.
Description
A lightweight Node.js SQLite query builder and database manager that constructs and executes structured SQL using declarative JavaScript objects.
Languages
JavaScript
100%