{"id":15050615,"url":"https://github.com/interactions-as-a-service/d1-orm","last_synced_at":"2025-04-06T00:07:15.633Z","repository":{"id":58252876,"uuid":"529976574","full_name":"Interactions-as-a-Service/d1-orm","owner":"Interactions-as-a-Service","description":"A simple, strictly typed ORM, to assist you in using Cloudflare's D1 product","archived":false,"fork":false,"pushed_at":"2024-09-01T12:55:56.000Z","size":516,"stargazers_count":168,"open_issues_count":8,"forks_count":9,"subscribers_count":5,"default_branch":"main","last_synced_at":"2025-04-06T00:07:09.688Z","etag":null,"topics":["cloudflare","cloudflare-d1","cloudflare-workers","d1","orm","typescript","workers"],"latest_commit_sha":null,"homepage":"https://docs.interactions.rest/d1-orm/","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Interactions-as-a-Service.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},"funding":{"custom":["https://www.buymeacoffee.com/Skye31"]}},"created_at":"2022-08-28T20:50:29.000Z","updated_at":"2025-03-19T05:59:32.000Z","dependencies_parsed_at":"2024-10-29T17:50:56.517Z","dependency_job_id":null,"html_url":"https://github.com/Interactions-as-a-Service/d1-orm","commit_stats":{"total_commits":78,"total_committers":5,"mean_commits":15.6,"dds":0.3076923076923077,"last_synced_commit":"35649b51c7a4b1367487bee152394b891518763f"},"previous_names":[],"tags_count":26,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Interactions-as-a-Service%2Fd1-orm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Interactions-as-a-Service%2Fd1-orm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Interactions-as-a-Service%2Fd1-orm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Interactions-as-a-Service%2Fd1-orm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Interactions-as-a-Service","download_url":"https://codeload.github.com/Interactions-as-a-Service/d1-orm/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247415967,"owners_count":20935388,"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":["cloudflare","cloudflare-d1","cloudflare-workers","d1","orm","typescript","workers"],"created_at":"2024-09-24T21:28:02.971Z","updated_at":"2025-04-06T00:07:15.614Z","avatar_url":"https://github.com/Interactions-as-a-Service.png","language":"TypeScript","funding_links":["https://www.buymeacoffee.com/Skye31"],"categories":[],"sub_categories":[],"readme":"# D1-Orm\n\n✨ A simple, strictly typed ORM, to assist you in using [Cloudflare's SQLite Database](https://developers.cloudflare.com/d1)\n\nDocs can be found at https://docs.interactions.rest/d1-orm/\n\nAPI reference can be found at https://orm.interactions.rest/modules\n\n## Installation\n\nThis package can be [found on NPM](https://npmjs.com/package/d1-orm)\n\n```sh\nnpm install d1-orm\n```\n\n## Usage\n\nThis package is recommended to be used with [@cloudflare/workers-types](https://github.com/cloudflare/workers-types) 4+.\n\n```ts\nimport { D1Orm, DataTypes, Model } from \"d1-orm\";\nimport type { Infer } from \"d1-orm\";\n\nexport interface Env {\n\t// from @cloudflare/workers-types\n\tDB: D1Database;\n}\n\nexport default {\n\tasync fetch(request: Request, env: Env) {\n\t\tconst orm = new D1Orm(env.DB);\n\t\tconst users = new Model(\n\t\t\t{\n\t\t\t\tD1Orm: orm,\n\t\t\t\ttableName: \"users\",\n\t\t\t\tprimaryKeys: \"id\",\n\t\t\t\tautoIncrement: \"id\",\n\t\t\t\tuniqueKeys: [[\"email\"]],\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: {\n\t\t\t\t\ttype: DataTypes.INTEGER,\n\t\t\t\t\tnotNull: true,\n\t\t\t\t},\n\t\t\t\tname: {\n\t\t\t\t\ttype: DataTypes.STRING,\n\t\t\t\t\tnotNull: true,\n\t\t\t\t\tdefaultValue: \"John Doe\",\n\t\t\t\t},\n\t\t\t\temail: {\n\t\t\t\t\ttype: DataTypes.STRING,\n\t\t\t\t},\n\t\t\t},\n\t\t);\n\t\ttype User = Infer\u003ctypeof users\u003e;\n\n\t\tawait users.First({\n\t\t\twhere: {\n\t\t\t\tid: 1,\n\t\t\t},\n\t\t});\n\t\t// Promise\u003cUser | null\u003e\n\t},\n};\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finteractions-as-a-service%2Fd1-orm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Finteractions-as-a-service%2Fd1-orm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finteractions-as-a-service%2Fd1-orm/lists"}