{"id":34656695,"url":"https://github.com/je-es/sdb","last_synced_at":"2025-12-24T18:09:32.265Z","repository":{"id":327529783,"uuid":"1109655608","full_name":"je-es/sdb","owner":"je-es","description":"A lightweight, type-safe SQLite database wrapper for Bun with an elegant API and zero dependencies.","archived":false,"fork":false,"pushed_at":"2025-12-04T12:39:13.000Z","size":78,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-12-07T11:45:06.333Z","etag":null,"topics":["bun","database","je-es","sqlite"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/je-es.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-12-04T05:20:32.000Z","updated_at":"2025-12-05T11:41:53.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/je-es/sdb","commit_stats":null,"previous_names":["je-es/sdb"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/je-es/sdb","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/je-es%2Fsdb","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/je-es%2Fsdb/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/je-es%2Fsdb/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/je-es%2Fsdb/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/je-es","download_url":"https://codeload.github.com/je-es/sdb/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/je-es%2Fsdb/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28005981,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-12-24T02:00:07.193Z","response_time":83,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bun","database","je-es","sqlite"],"created_at":"2025-12-24T18:05:43.181Z","updated_at":"2025-12-24T18:09:32.260Z","avatar_url":"https://github.com/je-es.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003c!-- ╔══════════════════════════════ BEG ══════════════════════════════╗ --\u003e\n\n\u003cbr\u003e\n\u003cdiv align=\"center\"\u003e\n    \u003cp\u003e\n        \u003cimg src=\"./assets/img/logo.png\" alt=\"logo\" style=\"\" height=\"80\" /\u003e\n    \u003c/p\u003e\n\u003c/div\u003e\n\n\u003cdiv align=\"center\"\u003e\n    \u003cimg src=\"https://img.shields.io/badge/v-0.0.2-black\"/\u003e\n    \u003cimg src=\"https://img.shields.io/badge/🔥-@je--es-black\"/\u003e\n    \u003cbr\u003e\n    \u003cimg src=\"https://github.com/je-es/sdb/actions/workflows/ci.yml/badge.svg\" alt=\"CI\" /\u003e\n    \u003cimg src=\"https://img.shields.io/badge/coverage-100%25-brightgreen\" alt=\"Test Coverage\" /\u003e\n    \u003cimg src=\"https://img.shields.io/github/issues/je-es/sdb?style=flat\" alt=\"Github Repo Issues\" /\u003e\n    \u003cimg src=\"https://img.shields.io/github/stars/je-es/sdb?style=social\" alt=\"GitHub Repo stars\" /\u003e\n\u003c/div\u003e\n\u003cbr\u003e\n\n\u003c!-- ╚═════════════════════════════════════════════════════════════════╝ --\u003e\n\n\n\n\u003c!-- ╔══════════════════════════════ DOC ══════════════════════════════╗ --\u003e\n\n- ## Quick Start 🔥\n\n    \u003e **A lightweight, type-safe SQLite database wrapper for Bun with an elegant API and zero dependencies.**\n\n    - #### Setup\n\n        \u003e install [`space`](https://github.com/solution-lib/space) first.\n\n        ```bash\n        # install\n        space i @je-es/sdb\n        ```\n\n        ```ts\n        // import\n        import { DB, table, integer, text, primaryKey, notNull, unique } from '@je-es/sdb';\n        ```\n\n    \u003cdiv align=\"center\"\u003e \u003cimg src=\"./assets/img/line.png\" alt=\"line\" style=\"display: block; margin-top:20px;margin-bottom:20px;width:500px;\"/\u003e \u003cbr\u003e \u003c/div\u003e\n\n    - #### Usage\n\n        - ##### Initialize Database\n            ```ts\n            // In-memory database\n            const db = new DB();\n\n            // Or file-based database\n            const db = new DB('./my-database.db');\n            ```\n\n        \u003cdiv align=\"center\"\u003e \u003cimg src=\"./assets/img/line.png\" alt=\"line\" style=\"display: block; margin-top:20px;margin-bottom:20px;width:500px;\"/\u003e \u003cbr\u003e \u003c/div\u003e\n\n        - ##### Define Schema\n            ```ts\n            import { table, integer, text, real, primaryKey, notNull, unique, defaultValue } from '@je-es/sdb';\n\n            // Define table schema\n            const usersSchema = table('users', [\n                primaryKey(integer('id'), true),  // auto-increment primary key\n                notNull(text('name')),\n                unique(text('email')),\n                integer('age'),\n                defaultValue(text('status'), 'active')\n            ]);\n\n            // Create the table\n            db.defineSchema(usersSchema);\n            ```\n\n        \u003cdiv align=\"center\"\u003e \u003cimg src=\"./assets/img/line.png\" alt=\"line\" style=\"display: block; margin-top:20px;margin-bottom:20px;width:500px;\"/\u003e \u003cbr\u003e \u003c/div\u003e\n\n        - ##### CRUD Operations\n            ```ts\n            // Insert\n            const user = db.insert('users', {\n                name: 'Alice',\n                email: 'alice@example.com',\n                age: 25\n            });\n\n            // Find by ID\n            const foundUser = db.findById('users', 1);\n\n            // Find one\n            const user = db.findOne('users', { email: 'alice@example.com' });\n\n            // Find many\n            const youngUsers = db.find('users', { status: 'active' });\n\n            // Get all\n            const allUsers = db.all('users');\n\n            // Update\n            db.update('users', 1, { age: 26 });\n\n            // Delete\n            db.delete('users', 1);\n            ```\n\n        \u003cdiv align=\"center\"\u003e \u003cimg src=\"./assets/img/line.png\" alt=\"line\" style=\"display: block; margin-top:20px;margin-bottom:20px;width:500px;\"/\u003e \u003cbr\u003e \u003c/div\u003e\n\n        - ##### Query Builder\n            ```ts\n            // Simple query\n            const results = db.query()\n                .select(['name', 'email'])\n                .from('users')\n                .where({ column: 'age', operator: '\u003e', value: 21 })\n                .orderBy('name', 'ASC')\n                .limit(10)\n                .execute();\n\n            // Complex query with multiple conditions\n            const activeUsers = db.query()\n                .select()\n                .from('users')\n                .where({ column: 'status', operator: '=', value: 'active' })\n                .and({ column: 'age', operator: '\u003e=', value: 18 })\n                .orderBy('name', 'ASC')\n                .execute();\n\n            // OR conditions\n            const users = db.query()\n                .select()\n                .from('users')\n                .where({ column: 'status', operator: '=', value: 'active' })\n                .or({ column: 'status', operator: '=', value: 'pending' })\n                .execute();\n\n            // IN operator\n            const specificUsers = db.query()\n                .select()\n                .from('users')\n                .where({ column: 'id', operator: 'IN', value: [1, 2, 3] })\n                .execute();\n\n            // LIKE operator\n            const searchResults = db.query()\n                .select()\n                .from('users')\n                .where({ column: 'name', operator: 'LIKE', value: 'A%' })\n                .execute();\n\n            // Pagination\n            const page2 = db.query()\n                .select()\n                .from('users')\n                .orderBy('id', 'ASC')\n                .limit(10)\n                .offset(10)\n                .execute();\n\n            // Get single result\n            const user = db.query()\n                .select()\n                .from('users')\n                .where({ column: 'email', operator: '=', value: 'test@example.com' })\n                .executeOne();\n            ```\n\n        \u003cdiv align=\"center\"\u003e \u003cimg src=\"./assets/img/line.png\" alt=\"line\" style=\"display: block; margin-top:20px;margin-bottom:20px;width:500px;\"/\u003e \u003cbr\u003e \u003c/div\u003e\n\n        - ##### Transactions\n            ```ts\n            db.transaction((txDb) =\u003e {\n                txDb.insert('users', { name: 'Alice', email: 'alice@example.com' });\n                txDb.insert('users', { name: 'Bob', email: 'bob@example.com' });\n                // Automatically commits if no error\n                // Automatically rolls back on error\n            });\n            ```\n\n        \u003cdiv align=\"center\"\u003e \u003cimg src=\"./assets/img/line.png\" alt=\"line\" style=\"display: block; margin-top:20px;margin-bottom:20px;width:500px;\"/\u003e \u003cbr\u003e \u003c/div\u003e\n\n        - ##### Raw SQL\n            ```ts\n            // Execute without return\n            db.exec('DELETE FROM users WHERE status = \"inactive\"');\n\n            // Execute with parameters and get results\n            const results = db.raw(\n                'SELECT * FROM users WHERE age \u003e ? AND status = ?',\n                [21, 'active']\n            );\n\n            // Get single result\n            const user = db.rawOne(\n                'SELECT * FROM users WHERE email = ?',\n                ['test@example.com']\n            );\n            ```\n\n        \u003cdiv align=\"center\"\u003e \u003cimg src=\"./assets/img/line.png\" alt=\"line\" style=\"display: block; margin-top:20px;margin-bottom:20px;width:500px;\"/\u003e \u003cbr\u003e \u003c/div\u003e\n\n        - ##### Foreign Keys \u0026 Indexes\n            ```ts\n            import { references } from '@je-es/sdb';\n\n            // Table with foreign key\n            const postsSchema = table('posts', [\n                primaryKey(integer('id'), true),\n                notNull(text('title')),\n                text('content'),\n                references(integer('user_id'), 'users', 'id')\n            ]);\n\n            // Foreign key with cascade delete\n            const ordersSchema = table('orders', [\n                primaryKey(integer('id'), true),\n                notNull(references(integer('user_id'), 'users', 'id', { onDelete: 'CASCADE' })),\n                text('description')\n            ]);\n\n            // Foreign key with set null on delete\n            const projectsSchema = table('projects', [\n                primaryKey(integer('id'), true),\n                text('name'),\n                references(integer('org_id'), 'organizations', 'id', { onDelete: 'SET NULL' })\n            ]);\n\n            // Table with indexes\n            const productsSchema = {\n                name: 'products',\n                columns: [\n                    { ...primaryKey(integer('id'), true) },\n                    { ...text('name') },\n                    { ...real('price') }\n                ],\n                indexes: [\n                    { name: 'idx_name', columns: ['name'] },\n                    { name: 'idx_price', columns: ['price'], unique: true }\n                ]\n            };\n\n            db.defineSchema(postsSchema);\n            db.defineSchema(ordersSchema);\n            db.defineSchema(projectsSchema);\n            db.defineSchema(productsSchema);\n            ```\n\n        \u003cdiv align=\"center\"\u003e \u003cimg src=\"./assets/img/line.png\" alt=\"line\" style=\"display: block; margin-top:20px;margin-bottom:20px;width:500px;\"/\u003e \u003cbr\u003e \u003c/div\u003e\n\n        - ##### Schema Management\n            ```ts\n            // Get table schema\n            const schema = db.getSchema('users');\n\n            // List all tables\n            const tables = db.listTables();\n\n            // Drop table\n            db.dropTable('old_table');\n\n            // Close database connection\n            db.close();\n            ```\n\n        \u003cdiv align=\"center\"\u003e \u003cimg src=\"./assets/img/line.png\" alt=\"line\" style=\"display: block; margin-top:20px;margin-bottom:20px;width:500px;\"/\u003e \u003cbr\u003e \u003c/div\u003e\n\n        - ##### Types\n\n          - ###### Column Types\n\n              - `integer(name)` - INTEGER column\n              - `text(name)` - TEXT column\n              - `real(name)` - REAL column (floating point)\n              - `blob(name)` - BLOB column (binary data)\n              - `numeric(name)` - NUMERIC column\n\n          - ###### Column Modifiers\n\n              - `primaryKey(col, autoIncrement?)` - Mark as primary key\n              - `notNull(col)` - Add NOT NULL constraint\n              - `unique(col)` - Add UNIQUE constraint\n              - `defaultValue(col, value)` - Set default value\n              - `references(col, table, column, options?)` - Add foreign key constraint with optional `onDelete` (`CASCADE` | `SET NULL` | `RESTRICT` | `NO ACTION` | `SET DEFAULT`) and `onUpdate` behavior\n\n\u003c!-- ╚═════════════════════════════════════════════════════════════════╝ --\u003e\n\n\n\n\u003c!-- ╔══════════════════════════════ END ══════════════════════════════╗ --\u003e\n\n\u003cbr\u003e\n\n---\n\n\u003cdiv align=\"center\"\u003e\n    \u003ca href=\"https://github.com/solution-lib/space\"\u003e\u003cimg src=\"https://img.shields.io/badge/by-Space-black\"/\u003e\u003c/a\u003e\n\u003c/div\u003e\n\n\u003c!-- ╚═════════════════════════════════════════════════════════════════╝ --\u003e","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fje-es%2Fsdb","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fje-es%2Fsdb","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fje-es%2Fsdb/lists"}