{"id":13632203,"url":"https://github.com/skoshx/pentagon","last_synced_at":"2025-10-16T23:31:15.137Z","repository":{"id":168065235,"uuid":"640409487","full_name":"skoshx/pentagon","owner":"skoshx","description":"Prisma-like ORM built on top of Deno KV. Allows you to write your database schemas and relations using Zod schemas, and run queries using familiar syntax from Prisma.","archived":false,"fork":false,"pushed_at":"2023-12-20T21:32:25.000Z","size":130,"stargazers_count":156,"open_issues_count":12,"forks_count":5,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-01-16T23:22:27.623Z","etag":null,"topics":["deno","denokv","orm","prisma","typescript"],"latest_commit_sha":null,"homepage":"https://dash.deno.com/playground/pentagon-demo","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/skoshx.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2023-05-14T01:48:14.000Z","updated_at":"2024-11-24T04:16:21.000Z","dependencies_parsed_at":null,"dependency_job_id":"6d59e536-0b83-4cb3-9e02-cc37df1a98cd","html_url":"https://github.com/skoshx/pentagon","commit_stats":null,"previous_names":["skoshx/pentagon"],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skoshx%2Fpentagon","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skoshx%2Fpentagon/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skoshx%2Fpentagon/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skoshx%2Fpentagon/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/skoshx","download_url":"https://codeload.github.com/skoshx/pentagon/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":236753507,"owners_count":19199461,"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":["deno","denokv","orm","prisma","typescript"],"created_at":"2024-08-01T22:02:56.124Z","updated_at":"2025-10-16T23:31:14.835Z","avatar_url":"https://github.com/skoshx.png","language":"TypeScript","funding_links":[],"categories":["TypeScript","Wrapper / ORM"],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n\t\u003cimg src=\"https://github.com/skoshx/pentagon/raw/main/docs/pentagon-banner.png\" /\u003e\n\u003c/p\u003e\n\n\u003csup\u003eSponsored by\u003c/sup\u003e\n\u003cbr /\u003e\n[![Flytrap](https://www.useflytrap.com/brand/flytrap-white-bg-1-8.svg)](https://www.useflytrap.com/?utm_campaign=github_repo\u0026utm_medium=referral\u0026utm_content=pentagon\u0026utm_source=github)\n\u003cbr /\u003e\n\u003cb\u003eA better way to understand your production bugs.\u003c/b\u003e\n\n\u003cdiv\u003e\n\t\u003csup\u003eSee all the data flowing through your code leading up to bugs. Flytrap allows you to fix bugs in production in a matter of minutes, instead of days.\u003c/sup\u003e\n\u003c/div\u003e\n\n# pentagon\n\n[![Test Github Action][github-actions-test-src]][github-actions-test-href]\n[![Lint Github Action][github-actions-lint-src]][github-actions-lint-href]\n\n\u003e Prisma like ORM built on top of Deno KV. Allows you to write your database\n\u003e schemas and relations using Zod schemas, and run queries using familiar syntax\n\u003e from Prisma.\n\n## Features\n\n- No codegen required, everything is inferred using Zod and TypeScript\n- All same functions as Prisma supported (not all yet implemented)\n- Support for `include`\n- Support for `select`\n- ~~Pagination~~ (todo)\n\n## 💻 Example usage\n\n```typescript\nimport { z } from \"https://deno.land/x/zod@v3.21.4/mod.ts\";\nimport { createPentagon } from \"https://deno.land/x/pentagon/mod.ts\";\nconst kv = await Deno.openKv();\n\nexport const User = z.object({\n  id: z.string().uuid().describe(\"primary\"),\n  createdAt: z.date(),\n  name: z.string(),\n});\n\nexport const Order = z.object({\n  id: z.string().uuid().describe(\"primary\"),\n  createdAt: z.date(),\n  name: z.string(),\n  userId: z.string().uuid(),\n});\n\nconst db = createPentagon(kv, {\n  users: {\n    schema: User,\n    relations: {\n      myOrders: [\"orders\", [Order], \"id\", \"userId\"],\n    },\n  },\n  orders: {\n    schema: Order,\n    relations: {\n      user: [\"users\", User, \"userId\", \"id\"],\n    },\n  },\n});\n\n// Now we have unlocked the magic of Pentagon\nconst user = await db.users.findFirst({\n  where: { name: \"John Doe\" },\n  select: { name: true, id: true },\n});\n\n// We can also do `include` queries, fully typed!\nconst userWithOrders = await db.users.findFirst({\n  where: { name: \"John Doe\" },\n  include: {\n    myOrders: true, // 👈 if we want the whole object\n    /* myOrders: { name: true }, 👈 if we want just some parts to be included */\n  },\n});\n```\n\n## Relations\n\nDefining relations works by defining the `relations` key in the table\ndefinition. This allows us to `include` the values of relations, the same way as\nwe are familiar with from Prisma.\n\nThe type signature\n[RelationDefinition](https://github.com/skoshx/pentagon/blob/fae437d373df89a1610a998e940c92213d3134b3/src/types.ts#LL56C24-L56C24)\nexplains what each of the array values represent.\n\nBasically, we have `[relation name, schema, local key, foreign key]`.\n\nFor instance, a many-to-one relation could look like this:\n\n```typescript\nusers: {\n  schema: User,\n  relations: {\n    myOrders: [\"orders\", [Order], undefined, \"userId\"],\n  },\n},\norders: {\n  schema: Order,\n  relations: {\n    user: [\"users\", User, \"userId\", \"id\"],\n  },\n},\n```\n\n## 💻 Development\n\nHelp is always appreciated, especially with getting the types right! Here's how\nyou can contribute:\n\n- Clone this repository\n- Fix types / add feature\n- Run the tests using `deno test --unstable`\n- Open PR\n\n## Running tests\n\n```bash\n$ deno test --unstable\n```\n\n## License\n\nMade with ❤️ in Helsinki, Finland.\n\nPublished under [MIT License](./LICENSE.md).\n\n\u003c!-- Links --\u003e\n\n[github-actions-test-href]: https://github.com/skoshx/pentagon/actions/workflows/test.yml\n[github-actions-lint-href]: https://github.com/skoshx/pentagon/actions/workflows/lint.yml\n\n\u003c!-- Badges --\u003e\n\n[github-actions-test-src]: https://github.com/skoshx/pentagon/actions/workflows/test.yml/badge.svg\n[github-actions-lint-src]: https://github.com/skoshx/pentagon/actions/workflows/lint.yml/badge.svg\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fskoshx%2Fpentagon","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fskoshx%2Fpentagon","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fskoshx%2Fpentagon/lists"}