From a1d14fa2b2197a071300e73bf071513ce2950a90 Mon Sep 17 00:00:00 2001 From: Benjamin Toby Date: Sun, 8 Mar 2026 08:33:49 +0100 Subject: [PATCH] Updates --- README.md | 58 ++++++++++++++++++++++++------------------------- dist/index.d.ts | 4 ++-- dist/index.js | 4 ++-- package.json | 2 +- src/index.ts | 4 ++-- 5 files changed, 36 insertions(+), 36 deletions(-) diff --git a/README.md b/README.md index 69569df..c91c744 100644 --- a/README.md +++ b/README.md @@ -120,27 +120,27 @@ This creates the SQLite database file and creates/updates all tables to match yo ### 4. Use the CRUD API ```ts -import NodeSQLite from "@moduletrace/nsqlite"; +import NSQLite from "@moduletrace/nsqlite"; // Insert -await NodeSQLite.insert({ +await NSQLite.insert({ table: "users", data: [{ first_name: "Alice", email: "alice@example.com" }], }); // Select -const result = await NodeSQLite.select({ table: "users" }); +const result = await NSQLite.select({ table: "users" }); console.log(result.payload); // Alice's row // Update -await NodeSQLite.update({ +await NSQLite.update({ table: "users", targetId: 1, data: { first_name: "Alicia" }, }); // Delete -await NodeSQLite.delete({ table: "users", targetId: 1 }); +await NSQLite.delete({ table: "users", targetId: 1 }); ``` --- @@ -323,7 +323,7 @@ npx nsqlite restore Import the default export: ```ts -import NodeSQLite from "@moduletrace/nsqlite"; +import NSQLite from "@moduletrace/nsqlite"; ``` All methods return an `APIResponseObject`: @@ -349,7 +349,7 @@ All methods return an `APIResponseObject`: ### Select ```ts -NodeSQLite.select({ table, query?, count?, targetId? }) +NSQLite.select({ table, query?, count?, targetId? }) ``` | Parameter | Type | Description | @@ -363,13 +363,13 @@ NodeSQLite.select({ table, query?, count?, targetId? }) ```ts // Get all users -const res = await NodeSQLite.select({ table: "users" }); +const res = await NSQLite.select({ table: "users" }); // Get by ID -const res = await NodeSQLite.select({ table: "users", targetId: 42 }); +const res = await NSQLite.select({ table: "users", targetId: 42 }); // Filter with LIKE -const res = await NodeSQLite.select({ +const res = await NSQLite.select({ table: "users", query: { query: { @@ -379,11 +379,11 @@ const res = await NodeSQLite.select({ }); // Count rows -const res = await NodeSQLite.select({ table: "users", count: true }); +const res = await NSQLite.select({ table: "users", count: true }); console.log(res.count); // Pagination -const res = await NodeSQLite.select({ +const res = await NSQLite.select({ table: "users", query: { limit: 10, page: 2 }, }); @@ -394,7 +394,7 @@ const res = await NodeSQLite.select({ ### Insert ```ts -NodeSQLite.insert({ table, data }); +NSQLite.insert({ table, data }); ``` | Parameter | Type | Description | @@ -407,7 +407,7 @@ NodeSQLite.insert({ table, data }); **Example:** ```ts -const res = await NodeSQLite.insert({ +const res = await NSQLite.insert({ table: "users", data: [ { first_name: "Alice", last_name: "Smith", email: "alice@example.com" }, @@ -423,7 +423,7 @@ console.log(res.postInsertReturn?.insertId); // last inserted row ID ### Update ```ts -NodeSQLite.update({ table, data, query?, targetId? }) +NSQLite.update({ table, data, query?, targetId? }) ``` | Parameter | Type | Description | @@ -441,14 +441,14 @@ A WHERE clause is required. If no condition matches, `success` is `false`. ```ts // Update by ID -await NodeSQLite.update({ +await NSQLite.update({ table: "users", targetId: 1, data: { first_name: "Alicia" }, }); // Update with custom query -await NodeSQLite.update({ +await NSQLite.update({ table: "users", data: { last_name: "Doe" }, query: { @@ -464,7 +464,7 @@ await NodeSQLite.update({ ### Delete ```ts -NodeSQLite.delete({ table, query?, targetId? }) +NSQLite.delete({ table, query?, targetId? }) ``` | Parameter | Type | Description | @@ -479,10 +479,10 @@ A WHERE clause is required. If no condition is provided, `success` is `false`. ```ts // Delete by ID -await NodeSQLite.delete({ table: "users", targetId: 1 }); +await NSQLite.delete({ table: "users", targetId: 1 }); // Delete with condition -await NodeSQLite.delete({ +await NSQLite.delete({ table: "users", query: { query: { @@ -497,7 +497,7 @@ await NodeSQLite.delete({ ### Raw SQL ```ts -NodeSQLite.sql({ sql, values? }) +NSQLite.sql({ sql, values? }) ``` | Parameter | Type | Description | @@ -511,11 +511,11 @@ SELECT statements return rows; all other statements return `postInsertReturn`. ```ts // SELECT -const res = await NodeSQLite.sql({ sql: "SELECT * FROM users" }); +const res = await NSQLite.sql({ sql: "SELECT * FROM users" }); console.log(res.payload); // INSERT with params -await NodeSQLite.sql({ +await NSQLite.sql({ sql: "INSERT INTO users (first_name, email) VALUES (?, ?)", values: ["Charlie", "charlie@example.com"], }); @@ -590,7 +590,7 @@ Set `equality` on any query field to control the comparison: ```ts // Find users with email NOT NULL, ordered by created_at DESC, limit 20 -const res = await NodeSQLite.select({ +const res = await NSQLite.select({ table: "users", query: { query: { @@ -605,7 +605,7 @@ const res = await NodeSQLite.select({ ### JOIN ```ts -const res = await NodeSQLite.select({ +const res = await NSQLite.select({ table: "posts", query: { join: [ @@ -669,7 +669,7 @@ npx nsqlite schema --vector ### Query vectors ```ts -const res = await NodeSQLite.select({ +const res = await NSQLite.select({ table: "documents", query: { query: { @@ -718,10 +718,10 @@ export type NSQLITE_MY_APP_ALL_TYPEDEFS = NSQLITE_MY_APP_USERS; // intersection Use the generated types with the CRUD API for full type safety: ```ts -import NodeSQLite from "@moduletrace/nsqlite"; +import NSQLite from "@moduletrace/nsqlite"; import { NSQLITE_MY_APP_USERS, NSQLiteTables } from "./db/types/db"; -const res = await NodeSQLite.select({ +const res = await NSQLite.select({ table: "users" as (typeof NSQLiteTables)[number], }); ``` @@ -745,7 +745,7 @@ Every table automatically receives the following fields — you do not need to d ``` node-sqlite/ ├── src/ -│ ├── index.ts # Main export (NodeSQLite object) +│ ├── index.ts # Main export (NSQLite object) │ ├── commands/ │ │ ├── index.ts # CLI entry point │ │ ├── schema.ts # `schema` command diff --git a/dist/index.d.ts b/dist/index.d.ts index a23f12e..a86233e 100644 --- a/dist/index.d.ts +++ b/dist/index.d.ts @@ -3,11 +3,11 @@ import DbInsert from "./lib/sqlite/db-insert"; import DbSelect from "./lib/sqlite/db-select"; import DbSQL from "./lib/sqlite/db-sql"; import DbUpdate from "./lib/sqlite/db-update"; -declare const NodeSQLite: { +declare const NSQLite: { readonly select: typeof DbSelect; readonly insert: typeof DbInsert; readonly update: typeof DbUpdate; readonly delete: typeof DbDelete; readonly sql: typeof DbSQL; }; -export default NodeSQLite; +export default NSQLite; diff --git a/dist/index.js b/dist/index.js index 3466e12..b3fb18a 100644 --- a/dist/index.js +++ b/dist/index.js @@ -8,11 +8,11 @@ const db_insert_1 = __importDefault(require("./lib/sqlite/db-insert")); const db_select_1 = __importDefault(require("./lib/sqlite/db-select")); const db_sql_1 = __importDefault(require("./lib/sqlite/db-sql")); const db_update_1 = __importDefault(require("./lib/sqlite/db-update")); -const NodeSQLite = { +const NSQLite = { select: db_select_1.default, insert: db_insert_1.default, update: db_update_1.default, delete: db_delete_1.default, sql: db_sql_1.default, }; -exports.default = NodeSQLite; +exports.default = NSQLite; diff --git a/package.json b/package.json index b90156e..f731a59 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@moduletrace/nsqlite", - "version": "1.0.2", + "version": "1.0.3", "description": "SQLite manager for Node JS", "author": "Benjamin Toby", "main": "dist/index.js", diff --git a/src/index.ts b/src/index.ts index f7996a8..b1c6c59 100644 --- a/src/index.ts +++ b/src/index.ts @@ -4,7 +4,7 @@ import DbSelect from "./lib/sqlite/db-select"; import DbSQL from "./lib/sqlite/db-sql"; import DbUpdate from "./lib/sqlite/db-update"; -const NodeSQLite = { +const NSQLite = { select: DbSelect, insert: DbInsert, update: DbUpdate, @@ -12,4 +12,4 @@ const NodeSQLite = { sql: DbSQL, } as const; -export default NodeSQLite; +export default NSQLite;