{"id":26663914,"url":"https://github.com/blobbybilb/tuplite","last_synced_at":"2025-04-11T20:10:24.798Z","repository":{"id":226690750,"uuid":"767355087","full_name":"blobbybilb/Tuplite","owner":"blobbybilb","description":"A zero-config, zero-SQL type based DB interface (for SQLite)","archived":false,"fork":false,"pushed_at":"2024-03-26T21:49:29.000Z","size":73823,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-25T15:39:11.452Z","etag":null,"topics":["db","orm","simple","sqlite","types","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"lgpl-2.1","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/blobbybilb.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}},"created_at":"2024-03-05T06:26:18.000Z","updated_at":"2024-03-29T10:40:14.000Z","dependencies_parsed_at":"2024-03-15T21:35:51.104Z","dependency_job_id":"315998d0-1e67-4376-bb31-4f784ecadedd","html_url":"https://github.com/blobbybilb/Tuplite","commit_stats":null,"previous_names":["blobbybilb/tuplite"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blobbybilb%2FTuplite","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blobbybilb%2FTuplite/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blobbybilb%2FTuplite/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blobbybilb%2FTuplite/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/blobbybilb","download_url":"https://codeload.github.com/blobbybilb/Tuplite/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248473127,"owners_count":21109628,"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","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":["db","orm","simple","sqlite","types","typescript"],"created_at":"2025-03-25T15:33:30.057Z","updated_at":"2025-04-11T20:10:24.771Z","avatar_url":"https://github.com/blobbybilb.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Tuplite\n\nA zero-config, zero-SQL type based DB interface (for SQLite)\n\nMade for TypeScript ~~and Python~~, and uses their type systems to provide a fully managed, type-safe, and easy to use DB interface. Not intended for high performance (it's a replacement for JSON files in a directory, not for ORMs/document DBs serving many users).\n\n## Install\n\n```bash\nnpm install tuplite # Node\ndeno add @blob/tuplite # Deno (when running, it requires --unstable-ffi)\nbun install tuplite # Bun\n\n```\n\n\u003c!-- pip install tuplite # Python (WIP) --\u003e\n\n## Usage\n\n**TypeScript:**\n\n```typescript\nimport { TupliteDB, type TupliteItem } from \"tuplite\";\n\n// Opens a DB file, or uses an in-memory DB if no path is given\n// Automatically uses the right SQLite library for Node/Deno/Bun\nconst db = await TupliteDB.open(\"test.db\");\n\n// Define your normal typescript type, extending TupliteItem to ensure it works with Tuplite\ninterface User extends TupliteItem {\n  id: number;\n  name: string;\n  active: boolean;\n}\n\n// Just give Tuplite your TS type and a table name. That's it! No SQL, schema-ing, etc.\nconst users = db.openTable\u003cUser\u003e(\"user\");\n\n// Start using your DB table with a simple interface, with full type checking!\nusers.add({ id: 1, name: \"test1\", active: true });\nusers.add({ id: 2, name: \"test2\", active: false });\n\n// Query the DB by 0 or more properties, again with full type checking\nusers.get({ id: 1 }); // [{ id: 1, name: \"test1\", active: true }]\n\n// Pass in a function for more advanced querying, with... full type checking!\nusers.get({ name: (name) =\u003e name.endsWith(\"2\") }); // [{ id: 2, name: \"test2\", active: false }]\n\n// updating and deleting is just as easy, and guess what it has? Full type checking!\nusers.mod({ id: 1 }, { name: \"test1-updated\" }); // modifies the 1st item to: [{ id: 1, name: \"test1-updated\", active: true }]\n\nusers.del({ active: false }); // deletes inactive users\n\n// Note: the db.openTable method takes a second optional argument, which is a list of indexes to create. Example:\nconst users = db.openTable\u003cUser\u003e(\"user\", [\"id\", \"name\"]); // creates indexes for the id and name columns, which can speed up read queries (but does come with an extra storage and write overhead)\n\n// And that's the entire API!\n```\n\n## History/Name\n\nThis project started as \"a python NamedTuple based interface to SQLite\" (hence the name) as part of another project, mostly because I didn't like SQL and wanted a zero-dev-overhead way to use SQLite. I then wanted something like this for a TypeScript project, so I made a TypeScript version that worked only in Bun, and added more features like querying by functions, powered by fun TypeScript stuff like this:\n\n```typescript\n// from types.ts\ntype TupliteItem = Record\u003cstring, TupliteValues\u003e;\ntype QueryItem\u003cT extends TupliteItem\u003e = {\n  [P in keyof T as string extends P ? never : P]?:\n    | T[P]\n    | ((arg: T[P]) =\u003e boolean);\n};\n```\n\nThen, I decided to make it a proper project, making it work with Deno and Node, and not doing questionable things like loading all the rows into memory when querying by functions (it now checks them one at a time). I made some final improvements (like allowing queries by function in `del` and `mod` as well as in `get`), and I think it is now feature complete and ready to be used.\n\nAs for a Python version: looking at what makes me like the TypeScript version and considering the differences in what the type systems of the two languages can do, I think I will wait until I need it for some project again. Currently, I don't think there's a way to make something like the TS mapped types above in Python, which would make it lose the things that make it nice/friendly to use, while still being much more narrow than existing libraries.\n\n## License\n\nLGPLv2.1\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fblobbybilb%2Ftuplite","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fblobbybilb%2Ftuplite","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fblobbybilb%2Ftuplite/lists"}