{"id":20600978,"url":"https://github.com/yuo-app/idb-orm","last_synced_at":"2026-02-16T15:34:12.933Z","repository":{"id":262895017,"uuid":"887774692","full_name":"yuo-app/idb-orm","owner":"yuo-app","description":"A lightweight, type-safe ORM for IndexedDB that closely matches the supabase-js API.","archived":false,"fork":false,"pushed_at":"2025-02-22T18:50:19.000Z","size":323,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-08-17T08:21:00.204Z","etag":null,"topics":["idb","indexeddb","orm","supabase","supabase-js"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yuo-app.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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-11-13T09:07:36.000Z","updated_at":"2024-11-24T15:42:41.000Z","dependencies_parsed_at":"2024-11-17T22:38:06.549Z","dependency_job_id":null,"html_url":"https://github.com/yuo-app/idb-orm","commit_stats":null,"previous_names":["yuo-app/idb-orm"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/yuo-app/idb-orm","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yuo-app%2Fidb-orm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yuo-app%2Fidb-orm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yuo-app%2Fidb-orm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yuo-app%2Fidb-orm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yuo-app","download_url":"https://codeload.github.com/yuo-app/idb-orm/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yuo-app%2Fidb-orm/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278708016,"owners_count":26031932,"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-10-06T02:00:05.630Z","response_time":65,"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":["idb","indexeddb","orm","supabase","supabase-js"],"created_at":"2024-11-16T09:07:45.658Z","updated_at":"2025-10-07T01:57:36.257Z","avatar_url":"https://github.com/yuo-app.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# idb-orm\n\nA lightweight, type-safe ORM for IndexedDB that closely matches the supabase-js API.\n\n## Install\n\n```bash\nnpm i @yuo-app/idb-orm\n```\n\n## Quick Start\n\n```typescript\nimport { type Database, type DatabaseSchema, IdbOrm } from '@yuo-app/idb-orm'\n\n// Define your database schema\nconst schema = {\n  users: {\n    id: { type: 'number', primaryKey: true },\n    name: { type: 'string', required: true },\n    age: { type: 'number' },\n  }\n} satisfies DatabaseSchema\n\n// Types are automatically inferred from schema\ntype DB = Database\u003ctypeof schema\u003e\ntype User = DB['users'] // { id: number, name: string, age?: number }\n\n// Initialize and connect\nconst db = new IdbOrm('database', 1, schema)\nawait db.connect()\n```\n\nDon't forget to increment the database version when you change the schema!\n\n## Schema\n\n### Ids\n\nUse `primaryKey: true` to define a primary key.\n\n- `type: 'number'` can be used to auto-increment the primary key combined with `autoIncrement: true`.\n- `type: 'string'` generates a UUID\n\n### Types\n\n`string`, `number`, `boolean`, `array`, `object`\n\nUse `required: true` to enforce a field to be non-nullable.\nUse `default` to set a default value.\n\n## API\n\n\u003e[!NOTE]\n\u003e idb-orm differs from supabase-js in one key way:\n\u003e\n\u003e - **you need to terminate chains with `get()` to execute them.**\n\u003e - `get()` will always return the modified data like when supabase's `select()` is called on insert methods.\n\n### Query Data\n\nUse `from()` to select a table, and `select()` to retrieve data.\n\n```typescript\nconst allUsers = await db\n  .from('users')\n  .select()\n  .get()\n```\n\n`select(...fields)` can be used to select specific fields.\n\n```typescript\nconst userIdsAndNames = await db\n  .from('users')\n  .select('id', 'name')\n  .get()\n```\n\n### Retrieve all data\n\n`getAll()` can be used to get the entire database.\n\n```typescript\nconst allData = await db.getAll()\n```\n\n### Insert records\n\n`insert()` will insert a new record and return the inserted data.\n\n\u003e[!TIP]\n\u003e It's recommended to use `upsert()` which directly inserts or updates a record.\n\u003e\n\u003e - use `insert()` only if you want it to fail when the record already exists\n\u003e - `update()` will not fail if the record does not exist, it will return an empty array\n\n```typescript\nawait db\n  .from('users')\n  .insert({ name: 'Me', age: 30 })\n  .get()\n```\n\nUse the `Insert` and `Update` helper types to create your actions.\n\n```typescript\ntype UserInsert = Insert\u003ctypeof schema['users']\u003e // id is optional, fields with default values are optional\ntype UserUpdate = Update\u003ctypeof schema['users']\u003e // all fields are optional (Partial\u003c\u003e also works)\n```\n\n### Update records\n\n`update()` will update records that match the query and return the updated data.\n\n```typescript\nawait db\n  .from('users')\n  .update({ age: 31 })\n  .eq('name', 'Me')\n  .get()\n```\n\n### Upsert records\n\n`upsert()` will insert a new record or update an existing record and return the data.\n\n```typescript\nawait db\n  .from('users')\n  .upsert({ name: 'Me', age: 31 })\n  .get()\n```\n\n### Delete records\n\n`delete()` will remove records that match the query.\n\n```typescript\nawait db\n  .from('users')\n  .delete()\n  .eq('name', 'Me')\n  .get()\n```\n\n### Filter records\n\nUse `eq()`, `neq()`, `gt()`, `gte()`, `lt()`, `lte()` to filter records.\n\n```typescript\nconst adults = await db\n  .from('users')\n  .select()\n  .gte('age', 18)\n  .get()\n```\n\n### Sort records\n\nSort records using `order(field, direction)`. Use `asc` or `desc` for the direction.\n\n```typescript\nconst sortedUsers = await db\n  .from('users')\n  .select()\n  .order('age', 'asc')\n  .get()\n```\n\n### Limit/offset records\n\nUse `limit()` to return the first N records. Combine this with `sort()` to get the last N records.\n\n```typescript\nconst firstUser = await db\n  .from('users')\n  .select()\n  .limit(3)\n  .get()\n```\n\n`offset()` can be used to skip the first N records.\n\n### Retrieve one row of data\n\n`single()` can be used instead of `get()` to return just one row of data, and not an array.\n\n```typescript\nconst user = await db\n  .from('users')\n  .limit(1)\n  .single()\n```\n\n### Get table names\n\nUse `getTableNames()` to get a list of table names.\n\n```typescript\nconst tableNames = await db.getTableNames() // ['users']\n```\n\n### Delete all data\n\n`clearAll()` will remove all data but keep the tables.\n`deleteAll()` will remove all data and tables.\n\n```typescript\nawait db.clearAll()\nawait db.deleteAll()\n```\n\n### License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyuo-app%2Fidb-orm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyuo-app%2Fidb-orm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyuo-app%2Fidb-orm/lists"}