{"id":24617810,"url":"https://github.com/jacoblincool/sveltekit-db","last_synced_at":"2025-09-03T20:48:57.220Z","repository":{"id":170826437,"uuid":"647092971","full_name":"JacobLinCool/sveltekit-db","owner":"JacobLinCool","description":"Isomorphic database for SvelteKit.","archived":false,"fork":false,"pushed_at":"2025-09-01T04:02:40.000Z","size":263,"stargazers_count":1,"open_issues_count":11,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-09-01T06:44:36.252Z","etag":null,"topics":[],"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/JacobLinCool.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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":"2023-05-30T03:37:27.000Z","updated_at":"2024-02-05T20:20:29.000Z","dependencies_parsed_at":"2023-09-27T08:14:24.123Z","dependency_job_id":"c363dbf3-d409-49e6-8794-8b6ee63cea7e","html_url":"https://github.com/JacobLinCool/sveltekit-db","commit_stats":null,"previous_names":["jacoblincool/sveltekit-db"],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/JacobLinCool/sveltekit-db","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JacobLinCool%2Fsveltekit-db","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JacobLinCool%2Fsveltekit-db/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JacobLinCool%2Fsveltekit-db/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JacobLinCool%2Fsveltekit-db/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/JacobLinCool","download_url":"https://codeload.github.com/JacobLinCool/sveltekit-db/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JacobLinCool%2Fsveltekit-db/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273509016,"owners_count":25118446,"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-09-03T02:00:09.631Z","response_time":76,"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":[],"created_at":"2025-01-24T23:41:04.317Z","updated_at":"2025-09-03T20:48:56.814Z","avatar_url":"https://github.com/JacobLinCool.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# SvelteKit DB\n\nCross-platform database solution for SvelteKit.\n\n```sh\npnpm i -D sveltekit-db\n```\n\n## Usage\n\n`sveltekit-db` uses `kysely` under the hood.\n\nYou can define your database schema like:\n\n```ts\n// src/lib/db/schema.ts\nexport interface User {\n    id: number;\n    name: string;\n    email: string;\n}\n\nexport interface Document {\n    id: number;\n    owner: number;\n    title: string;\n    content: string;\n}\n\nexport interface Database {\n    User: User;\n    Document: Document;\n}\n```\n\n```ts\n// src/lib/db/index.ts\nimport { DB } from \"sveltekit-db\";\nimport type { Database } from \"./schema\";\n\nexport const db = DB\u003cDatabase\u003e();\n```\n\nThen you can use it like:\n\n```ts\nimport { db } from \"$lib/db\";\nimport type { PageServerLoad } from \"./$types\";\n\nexport const load: PageServerLoad = async () =\u003e {\n    const documents = await db\n        .selectFrom(\"Document\")\n        .where(\"Document.owner\", \"=\", 1)\n        .select([\"Document.id\", \"Document.title\", \"Document.content\"])\n        .limit(10)\n        .execute();\n\n    return { documents };\n};\n```\n\n## Supported databases\n\n- [x] Cloudflare D1 (binding to `D1`, `DB`, or `DATABASE` environment variable)\n- [x] SQLite (using `SQLITE_FILE` environment variable, defaults to `db.sqlite`)\n\n## Configure with environment variables\n\nSee [src/lib/env.ts](src/lib/env.ts) for all available environment variable options.\n\n## Developing\n\nOnce you've installed dependencies with `pnpm install`, start a development server:\n\n```bash\npnpm dev\n```\n\nEverything inside `src/lib` is part of the library, everything inside `src/routes` is used as a showcase or preview app.\n\n## Building\n\nTo build the library:\n\n```bash\npnpm package\n```\n\nTo create a production version of the showcase app:\n\n```bash\npnpm build\n```\n\nYou can preview the production build with `pnpm preview`.\n\n\u003e To deploy the app, you may need to install an [adapter](https://kit.svelte.dev/docs/adapters) for the target environment.\n\n## Publishing\n\nTo publish the library to [npm](https://www.npmjs.com):\n\n```bash\npnpm publish\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjacoblincool%2Fsveltekit-db","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjacoblincool%2Fsveltekit-db","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjacoblincool%2Fsveltekit-db/lists"}