{"id":18609812,"url":"https://github.com/unlight/prisma-localization-experiment","last_synced_at":"2025-11-02T20:30:29.418Z","repository":{"id":138161419,"uuid":"323706315","full_name":"unlight/prisma-localization-experiment","owner":"unlight","description":"Prisma localization experiment","archived":false,"fork":false,"pushed_at":"2022-05-07T03:09:41.000Z","size":235,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-12-27T01:25:42.838Z","etag":null,"topics":["prisma","prisma2"],"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/unlight.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":"2020-12-22T18:41:19.000Z","updated_at":"2022-12-24T15:31:49.000Z","dependencies_parsed_at":null,"dependency_job_id":"c200f054-17fd-4668-973d-b9edabfa0e56","html_url":"https://github.com/unlight/prisma-localization-experiment","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/unlight%2Fprisma-localization-experiment","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/unlight%2Fprisma-localization-experiment/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/unlight%2Fprisma-localization-experiment/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/unlight%2Fprisma-localization-experiment/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/unlight","download_url":"https://codeload.github.com/unlight/prisma-localization-experiment/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239400596,"owners_count":19632049,"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":["prisma","prisma2"],"created_at":"2024-11-07T03:07:20.870Z","updated_at":"2025-11-02T20:30:29.371Z","avatar_url":"https://github.com/unlight.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# prisma-localization-experiment\n\nWhere localization is partial. For example,\n\n### Option 1\n\n```sh\nrm -f prisma/dev.db \u0026\u0026 npx prisma db push --preview-feature --force --schema prisma/schema.prisma \u0026\u0026 npx ts-node src/seed\nnpx ts-node src/feed\n```\n\n```prisma\nmodel Post {\n  postId    Int     @id @default(autoincrement())\n  title     String\n  titleLocalizations Localization[] @relation(name: \"TitleLocalizations\")\n  body String\n  bodyLocalizations Localization[] @relation(name: \"BodyLocalizations\")\n  categoryId Int?\n  category Category? @relation(fields: [categoryId], references: [categoryId])\n}\n\nmodel Category {\n  categoryId Int @id @default(autoincrement())\n  name String\n  nameLocalizations Localization[]\n  posts Post[]\n}\n\nmodel Localization {\n    localizationId Int @id @default(autoincrement())\n    language String // Enum\n    value String\n    titlePostId Int?\n    titlePost Post? @relation(name: \"TitleLocalizations\", fields: [titlePostId])\n    bodyPostId Int?\n    bodyPost Post? @relation(name: \"BodyLocalizations\", fields: [bodyPostId])\n}\n```\n\n#### Pros/Cons\n\n-   [-] Too explicit\n-   [-] Several loops to attach localized fields\n\n### Option 2\n\n```sh\nrm -f prisma/dev.db \u0026\u0026 npx prisma db push --preview-feature --force --schema prisma/schema2.prisma \u0026\u0026 npx ts-node src/seed2\nnpx ts-node src/feed2\n```\n\n```prisma\nmodel Post {\n  postId    Int     @id @default(autoincrement())\n  localizations Localization[]\n  title     String\n  body String\n  categoryId Int?\n  category Category? @relation(fields: [categoryId], references: [categoryId])\n}\n\nmodel Category {\n  categoryId Int @id @default(autoincrement())\n  localizations Localization[]\n  name String\n  posts Post[]\n}\n\nmodel Localization {\n    localizationId Int @id @default(autoincrement())\n    language String // Enum\n    field String\n    value String\n    postId Int?\n    post Post? @relation(fields: [postId], references: [postId])\n    categoryId Int?\n    category Category? @relation(fields: [categoryId], references: [categoryId])\n}\n```\n\n#### Pros/Cons\n\n-   [-] Single loop to attach localized fields\n-   [-] Less typings (like EAV field-value)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Funlight%2Fprisma-localization-experiment","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Funlight%2Fprisma-localization-experiment","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Funlight%2Fprisma-localization-experiment/lists"}