create-prisma 0.4.2-next.37.81.1 → 0.4.2-next.37.82.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -11,9 +11,10 @@ Scaffold a new app with Prisma Next already wired up.
11
11
  - scaffolds `prisma/contract.prisma` or `prisma/contract.ts`
12
12
  - scaffolds `prisma-next.config.ts`
13
13
  - writes a template-specific Prisma Next runtime helper
14
- - adds `contract:emit`, `db:init`, `db:update`, `db:seed`, `migration:plan`, and `migration:apply` scripts
14
+ - adds `contract:emit`, `db:init`, `db:update`, `db:verify`, `db:seed`, `migration:plan`, `migration:apply`, `migration:status`, and `migration:show` scripts
15
15
  - adds `db:up` / `db:down` and `docker-compose.yml` for default MongoDB projects
16
16
  - creates or updates `.env` with `DATABASE_URL`
17
+ - writes `.env.example`, `prisma-next.md`, and `.agents/skills/prisma-next/SKILL.md`
17
18
  - can install dependencies and run `prisma-next contract emit`
18
19
 
19
20
  `db:init`, migrations, and seeding are never run automatically. PostgreSQL projects show
package/dist/cli.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import "./create-C-bVmrxB.mjs";
2
+ import "./create-BpEvye82.mjs";
3
3
  import { createCreatePrismaCli } from "./index.mjs";
4
4
 
5
5
  //#region src/cli.ts
@@ -40,7 +40,7 @@ async function getAnonymousId() {
40
40
  }
41
41
  function getCommonProperties() {
42
42
  return {
43
- "cli-version": "0.4.2-next.37.81.1",
43
+ "cli-version": "0.4.2-next.37.82.1",
44
44
  "node-version": process.version,
45
45
  platform: process.platform,
46
46
  arch: process.arch
@@ -149,9 +149,11 @@ const dependencyVersionMap = {
149
149
  "@prisma-next/mongo": "0.4.4",
150
150
  "@prisma-next/mongo-contract": "0.4.4",
151
151
  "@prisma-next/mongo-contract-ts": "0.4.4",
152
+ "@prisma-next/mongo-orm": "0.4.4",
152
153
  "@prisma-next/postgres": "0.4.4",
153
154
  "@prisma-next/sql-contract": "0.4.4",
154
155
  "@prisma-next/sql-contract-ts": "0.4.4",
156
+ "@prisma-next/sql-orm-client": "0.4.4",
155
157
  "@prisma-next/target-mongo": "0.4.4",
156
158
  "@prisma-next/target-postgres": "0.4.4",
157
159
  "@types/node": "^25.6.2",
@@ -621,9 +623,12 @@ function getPrismaNextScriptMap(packageManager) {
621
623
  "contract:emit": `${prismaNextCli} contract emit`,
622
624
  "db:init": `${prismaNextCli} db init`,
623
625
  "db:update": `${prismaNextCli} db update`,
626
+ "db:verify": `${prismaNextCli} db verify`,
624
627
  "db:seed": "deno run -A --env-file=.env prisma/seed.ts",
625
628
  "migration:plan": `${prismaNextCli} migration plan`,
626
- "migration:apply": `${prismaNextCli} migration apply`
629
+ "migration:apply": `${prismaNextCli} migration apply`,
630
+ "migration:status": `${prismaNextCli} migration status`,
631
+ "migration:show": `${prismaNextCli} migration show`
627
632
  };
628
633
  }
629
634
  if (packageManager === "bun") {
@@ -632,18 +637,24 @@ function getPrismaNextScriptMap(packageManager) {
632
637
  "contract:emit": `${prismaNextCli} contract emit`,
633
638
  "db:init": `${prismaNextCli} db init`,
634
639
  "db:update": `${prismaNextCli} db update`,
640
+ "db:verify": `${prismaNextCli} db verify`,
635
641
  "db:seed": "bun prisma/seed.ts",
636
642
  "migration:plan": `${prismaNextCli} migration plan`,
637
- "migration:apply": `${prismaNextCli} migration apply`
643
+ "migration:apply": `${prismaNextCli} migration apply`,
644
+ "migration:status": `${prismaNextCli} migration status`,
645
+ "migration:show": `${prismaNextCli} migration show`
638
646
  };
639
647
  }
640
648
  return {
641
649
  "contract:emit": "prisma-next contract emit",
642
650
  "db:init": "prisma-next db init",
643
651
  "db:update": "prisma-next db update",
652
+ "db:verify": "prisma-next db verify",
644
653
  "db:seed": "tsx prisma/seed.ts",
645
654
  "migration:plan": "prisma-next migration plan",
646
- "migration:apply": "prisma-next migration apply"
655
+ "migration:apply": "prisma-next migration apply",
656
+ "migration:status": "prisma-next migration status",
657
+ "migration:show": "prisma-next migration show"
647
658
  };
648
659
  }
649
660
  function getVersion(packageName) {
@@ -685,6 +696,10 @@ function getMigrationPackages(provider) {
685
696
  if (provider === "mongo") return ["@prisma-next/family-mongo", "@prisma-next/target-mongo"];
686
697
  return ["@prisma-next/target-postgres"];
687
698
  }
699
+ function getOrmTypePackages(provider) {
700
+ if (provider === "mongo") return ["@prisma-next/mongo-orm"];
701
+ return ["@prisma-next/sql-orm-client"];
702
+ }
688
703
  async function addPackageDependency(opts) {
689
704
  const { dependencies = [], devDependencies = [], customDependencies = {}, scripts = {}, scriptMode, projectDir } = opts;
690
705
  const pkgJsonPath = path.join(projectDir, "package.json");
@@ -722,9 +737,10 @@ async function writePrismaDependencies(provider, packageManager, authoring, proj
722
737
  "@prisma-next/cli",
723
738
  "@types/node"
724
739
  ];
740
+ devDependencies.push(...getGeneratedContractTypePackages(provider));
725
741
  devDependencies.push(...getMigrationPackages(provider));
742
+ devDependencies.push(...getOrmTypePackages(provider));
726
743
  if (authoring === "typescript") devDependencies.push(...getTypeScriptContractPackages(provider));
727
- else if (packageManager === "deno") devDependencies.push(...getGeneratedContractTypePackages(provider));
728
744
  await addPackageDependency({
729
745
  dependencies,
730
746
  devDependencies,
@@ -847,6 +863,10 @@ const mongoDockerScripts = {
847
863
  "db:up": "docker compose up -d --wait",
848
864
  "db:down": "docker compose down"
849
865
  };
866
+ const minimumServerVersion = {
867
+ postgres: "14",
868
+ mongo: "6.0"
869
+ };
850
870
  const requiredPrismaFileGroups = [
851
871
  [
852
872
  "prisma/contract.prisma",
@@ -868,6 +888,221 @@ async function resolvePrismaProjectDir(projectDir) {
868
888
  if (await fs.pathExists(path.join(monorepoDbDir, "prisma/contract.prisma")) || await fs.pathExists(path.join(monorepoDbDir, "prisma/contract.ts"))) return monorepoDbDir;
869
889
  return projectDir;
870
890
  }
891
+ function getDatabaseLabel(provider) {
892
+ return provider === "mongo" ? "MongoDB" : "PostgreSQL";
893
+ }
894
+ function getContractPath(authoring) {
895
+ return `prisma/contract${authoring === "typescript" ? ".ts" : ".prisma"}`;
896
+ }
897
+ function stripTypeScriptExtension(filePath) {
898
+ return filePath.endsWith(".ts") ? filePath.slice(0, -3) : filePath;
899
+ }
900
+ async function findFirstExistingRelativePath(projectDir, candidates) {
901
+ for (const candidate of candidates) if (await fs.pathExists(path.join(projectDir, candidate))) return candidate;
902
+ }
903
+ async function readPackageScripts(projectDir) {
904
+ const packageJsonPath = path.join(projectDir, "package.json");
905
+ if (!await fs.pathExists(packageJsonPath)) return {};
906
+ const packageJson = await fs.readJson(packageJsonPath);
907
+ return typeof packageJson.scripts === "object" && packageJson.scripts !== null ? packageJson.scripts : {};
908
+ }
909
+ async function writeFileIfMissing(filePath, content) {
910
+ if (await fs.pathExists(filePath)) return;
911
+ await fs.outputFile(filePath, content.endsWith("\n") ? content : `${content}\n`, "utf8");
912
+ }
913
+ function getEnvExampleContent(provider) {
914
+ const label = getDatabaseLabel(provider);
915
+ const minVersion = minimumServerVersion[provider];
916
+ const databaseUrl = provider === "mongo" ? "mongodb://localhost:27017/mydb?replicaSet=rs0&directConnection=true" : "postgresql://user:password@localhost:5432/mydb";
917
+ return [
918
+ "# Copy this file to .env and replace the placeholder with your connection string.",
919
+ `# Requires ${label} >= ${minVersion}.`,
920
+ `DATABASE_URL="${databaseUrl}"`,
921
+ ""
922
+ ].join("\n");
923
+ }
924
+ function formatCommandListItem(packageManager, scriptName, description) {
925
+ return `- \`${getRunScriptCommand(packageManager, scriptName)}\` - ${description}`;
926
+ }
927
+ function getPrismaNextQuickReferenceContent(options) {
928
+ const { provider, authoring, schemaPreset, packageManager, schemaPath, dbImportPath, scripts, rootScripts } = options;
929
+ const label = getDatabaseLabel(provider);
930
+ const minVersion = minimumServerVersion[provider];
931
+ const hasWorkspaceRootDbUp = typeof scripts["db:up"] !== "string" && typeof rootScripts["db:up"] === "string";
932
+ const hasDbUp = typeof scripts["db:up"] === "string" || hasWorkspaceRootDbUp;
933
+ const commandLines = [
934
+ formatCommandListItem(packageManager, "contract:emit", "emit contract.json and contract.d.ts after contract changes"),
935
+ ...hasDbUp ? [formatCommandListItem(packageManager, "db:up", hasWorkspaceRootDbUp ? "start the local MongoDB replica set with Docker from the workspace root" : "start the local MongoDB replica set with Docker")] : [],
936
+ formatCommandListItem(packageManager, "db:init", "bootstrap a new database from the contract"),
937
+ formatCommandListItem(packageManager, "db:update", "apply contract changes directly after confirmation"),
938
+ formatCommandListItem(packageManager, "db:verify", "compare the live database state against the contract"),
939
+ formatCommandListItem(packageManager, "migration:plan", "write an offline migration plan from contract changes"),
940
+ formatCommandListItem(packageManager, "migration:apply", "apply pending migrations"),
941
+ formatCommandListItem(packageManager, "migration:status", "show applied and pending migrations"),
942
+ formatCommandListItem(packageManager, "migration:show", "inspect a planned migration"),
943
+ ...schemaPreset === "basic" ? [formatCommandListItem(packageManager, "db:seed", "insert starter sample data")] : []
944
+ ];
945
+ const workflowLines = provider === "mongo" ? [
946
+ "1. Start MongoDB with Docker if you are using the generated local database.",
947
+ "2. Run `contract:emit` after editing the contract.",
948
+ "3. Run `migration:plan` and review the generated migration.",
949
+ "4. Run `migration:apply` to apply pending migrations.",
950
+ "5. Run `db:seed` if you want the starter sample data."
951
+ ] : [
952
+ "1. Run `contract:emit` after editing the contract.",
953
+ "2. For first-time setup, run `db:init` to create and sign the database state.",
954
+ "3. For later contract changes, run `migration:plan` and `migration:apply`.",
955
+ "4. Run `db:seed` if you want the starter sample data."
956
+ ];
957
+ const queryExample = provider === "mongo" ? [
958
+ "```ts",
959
+ `import { db } from "${dbImportPath}";`,
960
+ "",
961
+ "for await (const user of db.orm.users.select(\"_id\", \"email\").take(10).all()) {",
962
+ " console.log(user.email);",
963
+ "}",
964
+ "```",
965
+ "",
966
+ "MongoDB accessors use the emitted collection names, so the starter `User` model is queried through `db.orm.users`. The Mongo facade connects lazily on the first query; call `db.close()` when a script is done. Use `db.query` for typed aggregation pipelines when the ORM cannot express a query."
967
+ ] : [
968
+ "```ts",
969
+ `import { db } from "${dbImportPath}";`,
970
+ "",
971
+ "const users = await db.orm.User.select(\"id\", \"email\").take(10).all();",
972
+ "```",
973
+ "",
974
+ "PostgreSQL models use their contract model names, so the starter `User` model is queried through `db.orm.User`. Prefer `db.orm` for application queries and use raw SQL only when the ORM does not cover the operation."
975
+ ];
976
+ return [
977
+ "# Prisma Next",
978
+ "",
979
+ `This project uses Prisma Next with ${label}. The contract is authored in ${authoring === "typescript" ? "TypeScript" : "PSL"} at \`${schemaPath}\`.`,
980
+ "",
981
+ "## Requirements",
982
+ "",
983
+ `- ${label} ${minVersion} or newer.`,
984
+ "- The generated `.env.example` shows the expected `DATABASE_URL` shape.",
985
+ ...provider === "mongo" ? ["- The generated Docker Compose setup starts MongoDB as a replica set for local migration workflows."] : [],
986
+ "",
987
+ "## Contract Artifacts",
988
+ "",
989
+ "Prisma Next emits two generated files next to the contract:",
990
+ "",
991
+ "- `prisma/contract.json` - runtime contract metadata",
992
+ "- `prisma/contract.d.ts` - TypeScript types for the contract",
993
+ "",
994
+ "Commit both generated files. Do not edit either one by hand.",
995
+ "",
996
+ "## Query Example",
997
+ "",
998
+ ...queryExample,
999
+ "",
1000
+ "## Commands",
1001
+ "",
1002
+ ...commandLines,
1003
+ "",
1004
+ "## Workflow",
1005
+ "",
1006
+ ...workflowLines,
1007
+ ""
1008
+ ].join("\n");
1009
+ }
1010
+ function getPrismaNextAgentSkillContent(options) {
1011
+ const { provider, authoring, schemaPreset, packageManager, schemaPath, dbImportPath, scripts, rootScripts } = options;
1012
+ const label = getDatabaseLabel(provider);
1013
+ const hasWorkspaceRootDbUp = typeof scripts["db:up"] !== "string" && typeof rootScripts["db:up"] === "string";
1014
+ const hasDbUp = typeof scripts["db:up"] === "string" || hasWorkspaceRootDbUp;
1015
+ const commands = [
1016
+ formatCommandListItem(packageManager, "contract:emit", "regenerate contract artifacts"),
1017
+ ...hasDbUp ? [formatCommandListItem(packageManager, "db:up", hasWorkspaceRootDbUp ? "start local MongoDB with Docker from the workspace root" : "start local MongoDB with Docker")] : [],
1018
+ formatCommandListItem(packageManager, "db:init", "bootstrap a new database"),
1019
+ formatCommandListItem(packageManager, "db:update", "apply contract changes directly"),
1020
+ formatCommandListItem(packageManager, "db:verify", "verify database state against the contract"),
1021
+ formatCommandListItem(packageManager, "migration:plan", "create an offline migration plan"),
1022
+ formatCommandListItem(packageManager, "migration:apply", "apply pending migrations"),
1023
+ formatCommandListItem(packageManager, "migration:status", "show migration status"),
1024
+ formatCommandListItem(packageManager, "migration:show", "inspect a migration"),
1025
+ ...schemaPreset === "basic" ? [formatCommandListItem(packageManager, "db:seed", "insert starter sample data")] : []
1026
+ ];
1027
+ const queryGuidance = provider === "mongo" ? [
1028
+ "- Use `db.orm.users` / `db.orm.posts`; Mongo accessors follow emitted collection names.",
1029
+ "- `.all()` returns an async iterable result, so `for await` is always safe.",
1030
+ "- Use `db.query` for typed aggregation pipelines.",
1031
+ "- The Mongo client connects lazily; scripts should call `await db.close()` in `finally`.",
1032
+ "- Local MongoDB should run as a replica set for migration workflows."
1033
+ ] : [
1034
+ "- Use `db.orm.User` / `db.orm.Post`; PostgreSQL accessors follow contract model names.",
1035
+ "- Prefer `db.orm` for application queries.",
1036
+ "- Use raw SQL only when the ORM cannot express the operation.",
1037
+ "- Close script runtimes with `await db.runtime().close()` when needed."
1038
+ ];
1039
+ return [
1040
+ "# Prisma Next Project Skill",
1041
+ "",
1042
+ `This project uses Prisma Next with ${label}. The contract is \`${schemaPath}\` using ${authoring === "typescript" ? "TypeScript" : "PSL"} authoring.`,
1043
+ "",
1044
+ "## Files",
1045
+ "",
1046
+ `- Contract: \`${schemaPath}\``,
1047
+ "- Config: `prisma-next.config.ts`",
1048
+ `- Database helper: import \`db\` from \`${dbImportPath}\``,
1049
+ "- Generated files: `prisma/contract.json` and `prisma/contract.d.ts`",
1050
+ "",
1051
+ "## Rules",
1052
+ "",
1053
+ "- Never edit generated contract artifacts by hand.",
1054
+ "- Run `contract:emit` after contract edits before relying on new types.",
1055
+ "- Do not auto-run `db:init`, migrations, or seed commands.",
1056
+ ...queryGuidance,
1057
+ "",
1058
+ "## Commands",
1059
+ "",
1060
+ ...commands,
1061
+ "",
1062
+ "## Common Workflow",
1063
+ "",
1064
+ "- Edit the contract.",
1065
+ "- Run `contract:emit`.",
1066
+ "- For a new database, run `db:init`.",
1067
+ "- For existing databases, run `migration:plan`, review it, then run `migration:apply`.",
1068
+ "- Run `db:verify` or `migration:status` when checking state.",
1069
+ ""
1070
+ ].join("\n");
1071
+ }
1072
+ async function writePrismaNextProjectDocs(options) {
1073
+ const prismaProjectDir = await resolvePrismaProjectDir(options.projectDir);
1074
+ const schemaPath = getContractPath(options.authoring);
1075
+ const dbImportPath = `./${stripTypeScriptExtension(await findFirstExistingRelativePath(prismaProjectDir, [
1076
+ "src/lib/prisma.ts",
1077
+ "src/lib/prisma.server.ts",
1078
+ "src/lib/server/prisma.ts",
1079
+ "server/utils/prisma.ts",
1080
+ "src/client.ts"
1081
+ ]) ?? "src/lib/prisma.ts")}`;
1082
+ const scripts = await readPackageScripts(prismaProjectDir);
1083
+ const rootScripts = await readPackageScripts(options.projectDir);
1084
+ await writeFileIfMissing(path.join(prismaProjectDir, ".env.example"), getEnvExampleContent(options.provider));
1085
+ await writeFileIfMissing(path.join(prismaProjectDir, "prisma-next.md"), getPrismaNextQuickReferenceContent({
1086
+ provider: options.provider,
1087
+ authoring: options.authoring,
1088
+ schemaPreset: options.schemaPreset,
1089
+ packageManager: options.packageManager,
1090
+ schemaPath,
1091
+ dbImportPath,
1092
+ scripts,
1093
+ rootScripts
1094
+ }));
1095
+ await writeFileIfMissing(path.join(prismaProjectDir, ".agents/skills/prisma-next/SKILL.md"), getPrismaNextAgentSkillContent({
1096
+ provider: options.provider,
1097
+ authoring: options.authoring,
1098
+ schemaPreset: options.schemaPreset,
1099
+ packageManager: options.packageManager,
1100
+ schemaPath,
1101
+ dbImportPath,
1102
+ scripts,
1103
+ rootScripts
1104
+ }));
1105
+ }
871
1106
  async function promptForDatabaseProvider() {
872
1107
  const databaseProvider = await select({
873
1108
  message: "Select your database",
@@ -1239,6 +1474,21 @@ async function finalizePrismaFilesForContext(context, projectDir, provisionResul
1239
1474
  return false;
1240
1475
  }
1241
1476
  }
1477
+ async function writePrismaNextProjectDocsForContext(context, projectDir) {
1478
+ try {
1479
+ await writePrismaNextProjectDocs({
1480
+ provider: context.databaseProvider,
1481
+ authoring: context.authoring,
1482
+ schemaPreset: context.schemaPreset,
1483
+ packageManager: context.packageManager,
1484
+ projectDir
1485
+ });
1486
+ return true;
1487
+ } catch (error) {
1488
+ cancel(getCommandErrorMessage(error));
1489
+ return false;
1490
+ }
1491
+ }
1242
1492
  function getPrismaNextCliCommand(packageManager, prismaNextArgs) {
1243
1493
  if (packageManager === "deno") return `deno run -A --env-file=.env npm:prisma-next@${dependencyVersionMap["prisma-next"]} ${prismaNextArgs.join(" ")}`;
1244
1494
  return getLocalPackageBinaryCommand(packageManager, "prisma-next", prismaNextArgs);
@@ -1339,6 +1589,7 @@ async function executePrismaSetupContext(context, options = {}) {
1339
1589
  if (!await installDependenciesForContext(context, projectDir)) return false;
1340
1590
  if (!await finalizePrismaFilesForContext(context, projectDir, provisionResult)) return false;
1341
1591
  if (!await writeMongoDockerHelpersForContext(context, projectDir)) return false;
1592
+ if (!await writePrismaNextProjectDocsForContext(context, projectDir)) return false;
1342
1593
  const emitResult = await emitPrismaNextContractForContext(context, projectDir);
1343
1594
  const warningLines = buildWarningLines(provisionResult.warning, emitResult.warning);
1344
1595
  const nextSteps = buildNextStepsForContext({
package/dist/index.mjs CHANGED
@@ -1,10 +1,10 @@
1
1
  #!/usr/bin/env node
2
- import { a as DatabaseProviderSchema, c as SchemaPresetSchema, i as CreateTemplateSchema, n as AuthoringStyleSchema, o as DatabaseUrlSchema, r as CreateCommandInputSchema, s as PackageManagerSchema, t as runCreateCommand } from "./create-C-bVmrxB.mjs";
2
+ import { a as DatabaseProviderSchema, c as SchemaPresetSchema, i as CreateTemplateSchema, n as AuthoringStyleSchema, o as DatabaseUrlSchema, r as CreateCommandInputSchema, s as PackageManagerSchema, t as runCreateCommand } from "./create-BpEvye82.mjs";
3
3
  import { os } from "@orpc/server";
4
4
  import { createCli } from "trpc-cli";
5
5
 
6
6
  //#region src/index.ts
7
- const CLI_VERSION = "0.4.2-next.37.81.1";
7
+ const CLI_VERSION = "0.4.2-next.37.82.1";
8
8
  const router = os.router({ create: os.meta({
9
9
  description: "Create a new project with Prisma setup",
10
10
  default: true,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-prisma",
3
- "version": "0.4.2-next.37.81.1",
3
+ "version": "0.4.2-next.37.82.1",
4
4
  "private": false,
5
5
  "description": "Create Prisma Next projects with first-party templates and great DX.",
6
6
  "homepage": "https://github.com/prisma/create-prisma",
@@ -36,6 +36,8 @@ Database helper scripts are added to `package.json`:
36
36
  - `{{runScriptCommand packageManager "db:seed"}}` - insert sample users manually
37
37
  {{/if}}
38
38
 
39
+ See `prisma-next.md` and `.agents/skills/prisma-next/SKILL.md` for provider-specific Prisma Next workflow notes.
40
+
39
41
  Node-based Prisma Next projects expect Node.js 24 LTS or newer.
40
42
  {{#if (eq schemaPreset "basic")}}
41
43
 
@@ -4,6 +4,13 @@ import mongo from "@prisma-next/mongo/runtime";
4
4
  {{else}}
5
5
  import postgres from "@prisma-next/postgres/runtime";
6
6
  {{/if}}
7
+ {{#if (eq schemaPreset "basic")}}
8
+ {{#if (eq provider "mongo")}}
9
+ import type { DefaultModelRow } from "@prisma-next/mongo-orm";
10
+ {{else}}
11
+ import type { DefaultModelRow } from "@prisma-next/sql-orm-client";
12
+ {{/if}}
13
+ {{/if}}
7
14
  import type { Contract } from "../../prisma/contract.d";
8
15
  import contractJson from "../../prisma/contract.json" with { type: "json" };
9
16
 
@@ -19,41 +26,50 @@ export const db = postgres<Contract>({
19
26
  });
20
27
  {{/if}}
21
28
 
22
- export type StarterUser = {
23
- id: string;
24
- email: string;
25
- name: string | null;
26
- createdAt: Date | null;
27
- };
29
+ {{#if (eq schemaPreset "basic")}}
30
+ type UserRow = DefaultModelRow<Contract, "User">;
31
+
32
+ {{#if (eq provider "mongo")}}
33
+ function toStarterUser(user: Pick<UserRow, "_id" | "email" | "name">) {
34
+ return {
35
+ id: String(user._id),
36
+ email: user.email,
37
+ name: user.name ?? null,
38
+ createdAt: null,
39
+ };
40
+ }
41
+ {{else}}
42
+ function toStarterUser(user: Pick<UserRow, "id" | "email" | "name" | "createdAt">) {
43
+ return {
44
+ id: String(user.id),
45
+ email: user.email,
46
+ name: user.name ?? null,
47
+ createdAt: user.createdAt,
48
+ };
49
+ }
50
+ {{/if}}
51
+ {{/if}}
28
52
 
29
- export async function listUsers(limit = 10): Promise<StarterUser[]> {
53
+ export async function listUsers(limit = 10) {
30
54
  {{#if (eq schemaPreset "basic")}}
31
55
  {{#if (eq provider "mongo")}}
32
- const users: StarterUser[] = [];
56
+ const users: ReturnType<typeof toStarterUser>[] = [];
33
57
 
34
58
  for await (const user of db.orm.users.select("_id", "email", "name").take(limit).all()) {
35
- users.push({
36
- id: String(user._id),
37
- email: user.email,
38
- name: user.name ?? null,
39
- createdAt: null,
40
- });
59
+ users.push(toStarterUser(user));
41
60
  }
42
61
 
43
62
  return users;
44
63
  {{else}}
45
64
  const users = await db.orm.User.select("id", "email", "name", "createdAt").take(limit).all();
46
65
 
47
- return users.map((user) => ({
48
- id: String(user.id),
49
- email: user.email,
50
- name: user.name ?? null,
51
- createdAt: user.createdAt,
52
- }));
66
+ return users.map(toStarterUser);
53
67
  {{/if}}
54
68
  {{else}}
55
69
  return [];
56
70
  {{/if}}
57
71
  }
58
72
 
73
+ export type StarterUser = Awaited<ReturnType<typeof listUsers>>[number];
74
+
59
75
  export default db;
@@ -34,6 +34,8 @@ Database helper scripts are added to `package.json`:
34
34
  - `{{runScriptCommand packageManager "db:seed"}}` - insert sample users manually
35
35
  {{/if}}
36
36
 
37
+ See `prisma-next.md` and `.agents/skills/prisma-next/SKILL.md` for provider-specific Prisma Next workflow notes.
38
+
37
39
  Node-based Prisma Next projects expect Node.js 24 LTS or newer.
38
40
  {{#if (eq schemaPreset "basic")}}
39
41
 
@@ -4,6 +4,13 @@ import mongo from "@prisma-next/mongo/runtime";
4
4
  {{else}}
5
5
  import postgres from "@prisma-next/postgres/runtime";
6
6
  {{/if}}
7
+ {{#if (eq schemaPreset "basic")}}
8
+ {{#if (eq provider "mongo")}}
9
+ import type { DefaultModelRow } from "@prisma-next/mongo-orm";
10
+ {{else}}
11
+ import type { DefaultModelRow } from "@prisma-next/sql-orm-client";
12
+ {{/if}}
13
+ {{/if}}
7
14
  import type { Contract } from "../../prisma/contract.d";
8
15
  import contractJson from "../../prisma/contract.json" with { type: "json" };
9
16
 
@@ -19,41 +26,50 @@ export const db = postgres<Contract>({
19
26
  });
20
27
  {{/if}}
21
28
 
22
- export type StarterUser = {
23
- id: string;
24
- email: string;
25
- name: string | null;
26
- createdAt: Date | null;
27
- };
29
+ {{#if (eq schemaPreset "basic")}}
30
+ type UserRow = DefaultModelRow<Contract, "User">;
31
+
32
+ {{#if (eq provider "mongo")}}
33
+ function toStarterUser(user: Pick<UserRow, "_id" | "email" | "name">) {
34
+ return {
35
+ id: String(user._id),
36
+ email: user.email,
37
+ name: user.name ?? null,
38
+ createdAt: null,
39
+ };
40
+ }
41
+ {{else}}
42
+ function toStarterUser(user: Pick<UserRow, "id" | "email" | "name" | "createdAt">) {
43
+ return {
44
+ id: String(user.id),
45
+ email: user.email,
46
+ name: user.name ?? null,
47
+ createdAt: user.createdAt,
48
+ };
49
+ }
50
+ {{/if}}
51
+ {{/if}}
28
52
 
29
- export async function listUsers(limit = 10): Promise<StarterUser[]> {
53
+ export async function listUsers(limit = 10) {
30
54
  {{#if (eq schemaPreset "basic")}}
31
55
  {{#if (eq provider "mongo")}}
32
- const users: StarterUser[] = [];
56
+ const users: ReturnType<typeof toStarterUser>[] = [];
33
57
 
34
58
  for await (const user of db.orm.users.select("_id", "email", "name").take(limit).all()) {
35
- users.push({
36
- id: String(user._id),
37
- email: user.email,
38
- name: user.name ?? null,
39
- createdAt: null,
40
- });
59
+ users.push(toStarterUser(user));
41
60
  }
42
61
 
43
62
  return users;
44
63
  {{else}}
45
64
  const users = await db.orm.User.select("id", "email", "name", "createdAt").take(limit).all();
46
65
 
47
- return users.map((user) => ({
48
- id: String(user.id),
49
- email: user.email,
50
- name: user.name ?? null,
51
- createdAt: user.createdAt,
52
- }));
66
+ return users.map(toStarterUser);
53
67
  {{/if}}
54
68
  {{else}}
55
69
  return [];
56
70
  {{/if}}
57
71
  }
58
72
 
73
+ export type StarterUser = Awaited<ReturnType<typeof listUsers>>[number];
74
+
59
75
  export default db;
@@ -34,6 +34,8 @@ Database helper scripts are added to `package.json`:
34
34
  - `{{runScriptCommand packageManager "db:seed"}}` - insert sample users manually
35
35
  {{/if}}
36
36
 
37
+ See `prisma-next.md` and `.agents/skills/prisma-next/SKILL.md` for provider-specific Prisma Next workflow notes.
38
+
37
39
  Node-based Prisma Next projects expect Node.js 24 LTS or newer.
38
40
  {{#if (eq schemaPreset "basic")}}
39
41
 
@@ -4,6 +4,13 @@ import mongo from "@prisma-next/mongo/runtime";
4
4
  {{else}}
5
5
  import postgres from "@prisma-next/postgres/runtime";
6
6
  {{/if}}
7
+ {{#if (eq schemaPreset "basic")}}
8
+ {{#if (eq provider "mongo")}}
9
+ import type { DefaultModelRow } from "@prisma-next/mongo-orm";
10
+ {{else}}
11
+ import type { DefaultModelRow } from "@prisma-next/sql-orm-client";
12
+ {{/if}}
13
+ {{/if}}
7
14
  import type { Contract } from "../../prisma/contract.d";
8
15
  import contractJson from "../../prisma/contract.json" with { type: "json" };
9
16
 
@@ -19,41 +26,50 @@ export const db = postgres<Contract>({
19
26
  });
20
27
  {{/if}}
21
28
 
22
- export type StarterUser = {
23
- id: string;
24
- email: string;
25
- name: string | null;
26
- createdAt: Date | null;
27
- };
29
+ {{#if (eq schemaPreset "basic")}}
30
+ type UserRow = DefaultModelRow<Contract, "User">;
31
+
32
+ {{#if (eq provider "mongo")}}
33
+ function toStarterUser(user: Pick<UserRow, "_id" | "email" | "name">) {
34
+ return {
35
+ id: String(user._id),
36
+ email: user.email,
37
+ name: user.name ?? null,
38
+ createdAt: null,
39
+ };
40
+ }
41
+ {{else}}
42
+ function toStarterUser(user: Pick<UserRow, "id" | "email" | "name" | "createdAt">) {
43
+ return {
44
+ id: String(user.id),
45
+ email: user.email,
46
+ name: user.name ?? null,
47
+ createdAt: user.createdAt,
48
+ };
49
+ }
50
+ {{/if}}
51
+ {{/if}}
28
52
 
29
- export async function listUsers(limit = 10): Promise<StarterUser[]> {
53
+ export async function listUsers(limit = 10) {
30
54
  {{#if (eq schemaPreset "basic")}}
31
55
  {{#if (eq provider "mongo")}}
32
- const users: StarterUser[] = [];
56
+ const users: ReturnType<typeof toStarterUser>[] = [];
33
57
 
34
58
  for await (const user of db.orm.users.select("_id", "email", "name").take(limit).all()) {
35
- users.push({
36
- id: String(user._id),
37
- email: user.email,
38
- name: user.name ?? null,
39
- createdAt: null,
40
- });
59
+ users.push(toStarterUser(user));
41
60
  }
42
61
 
43
62
  return users;
44
63
  {{else}}
45
64
  const users = await db.orm.User.select("id", "email", "name", "createdAt").take(limit).all();
46
65
 
47
- return users.map((user) => ({
48
- id: String(user.id),
49
- email: user.email,
50
- name: user.name ?? null,
51
- createdAt: user.createdAt,
52
- }));
66
+ return users.map(toStarterUser);
53
67
  {{/if}}
54
68
  {{else}}
55
69
  return [];
56
70
  {{/if}}
57
71
  }
58
72
 
73
+ export type StarterUser = Awaited<ReturnType<typeof listUsers>>[number];
74
+
59
75
  export default db;
@@ -35,6 +35,8 @@ Database helper scripts are added to `package.json`:
35
35
  - `{{runScriptCommand packageManager "db:seed"}}` - insert sample users manually
36
36
  {{/if}}
37
37
 
38
+ See `prisma-next.md` and `.agents/skills/prisma-next/SKILL.md` for provider-specific Prisma Next workflow notes.
39
+
38
40
  Node-based Prisma Next projects expect Node.js 24 LTS or newer.
39
41
  {{#if (eq schemaPreset "basic")}}
40
42
 
@@ -4,6 +4,13 @@ import mongo from "@prisma-next/mongo/runtime";
4
4
  {{else}}
5
5
  import postgres from "@prisma-next/postgres/runtime";
6
6
  {{/if}}
7
+ {{#if (eq schemaPreset "basic")}}
8
+ {{#if (eq provider "mongo")}}
9
+ import type { DefaultModelRow } from "@prisma-next/mongo-orm";
10
+ {{else}}
11
+ import type { DefaultModelRow } from "@prisma-next/sql-orm-client";
12
+ {{/if}}
13
+ {{/if}}
7
14
  import type { Contract } from "../../prisma/contract.d";
8
15
  import contractJson from "../../prisma/contract.json" with { type: "json" };
9
16
 
@@ -19,41 +26,50 @@ export const db = postgres<Contract>({
19
26
  });
20
27
  {{/if}}
21
28
 
22
- export type StarterUser = {
23
- id: string;
24
- email: string;
25
- name: string | null;
26
- createdAt: Date | null;
27
- };
29
+ {{#if (eq schemaPreset "basic")}}
30
+ type UserRow = DefaultModelRow<Contract, "User">;
31
+
32
+ {{#if (eq provider "mongo")}}
33
+ function toStarterUser(user: Pick<UserRow, "_id" | "email" | "name">) {
34
+ return {
35
+ id: String(user._id),
36
+ email: user.email,
37
+ name: user.name ?? null,
38
+ createdAt: null,
39
+ };
40
+ }
41
+ {{else}}
42
+ function toStarterUser(user: Pick<UserRow, "id" | "email" | "name" | "createdAt">) {
43
+ return {
44
+ id: String(user.id),
45
+ email: user.email,
46
+ name: user.name ?? null,
47
+ createdAt: user.createdAt,
48
+ };
49
+ }
50
+ {{/if}}
51
+ {{/if}}
28
52
 
29
- export async function listUsers(limit = 10): Promise<StarterUser[]> {
53
+ export async function listUsers(limit = 10) {
30
54
  {{#if (eq schemaPreset "basic")}}
31
55
  {{#if (eq provider "mongo")}}
32
- const users: StarterUser[] = [];
56
+ const users: ReturnType<typeof toStarterUser>[] = [];
33
57
 
34
58
  for await (const user of db.orm.users.select("_id", "email", "name").take(limit).all()) {
35
- users.push({
36
- id: String(user._id),
37
- email: user.email,
38
- name: user.name ?? null,
39
- createdAt: null,
40
- });
59
+ users.push(toStarterUser(user));
41
60
  }
42
61
 
43
62
  return users;
44
63
  {{else}}
45
64
  const users = await db.orm.User.select("id", "email", "name", "createdAt").take(limit).all();
46
65
 
47
- return users.map((user) => ({
48
- id: String(user.id),
49
- email: user.email,
50
- name: user.name ?? null,
51
- createdAt: user.createdAt,
52
- }));
66
+ return users.map(toStarterUser);
53
67
  {{/if}}
54
68
  {{else}}
55
69
  return [];
56
70
  {{/if}}
57
71
  }
58
72
 
73
+ export type StarterUser = Awaited<ReturnType<typeof listUsers>>[number];
74
+
59
75
  export default db;
@@ -34,6 +34,8 @@ Database helper scripts are added to `package.json`:
34
34
  - `{{runScriptCommand packageManager "db:seed"}}` - insert sample users manually
35
35
  {{/if}}
36
36
 
37
+ See `prisma-next.md` and `.agents/skills/prisma-next/SKILL.md` for provider-specific Prisma Next workflow notes.
38
+
37
39
  Node-based Prisma Next projects expect Node.js 24 LTS or newer.
38
40
  {{#if (eq schemaPreset "basic")}}
39
41
 
@@ -4,6 +4,13 @@ import mongo from "@prisma-next/mongo/runtime";
4
4
  {{else}}
5
5
  import postgres from "@prisma-next/postgres/runtime";
6
6
  {{/if}}
7
+ {{#if (eq schemaPreset "basic")}}
8
+ {{#if (eq provider "mongo")}}
9
+ import type { DefaultModelRow } from "@prisma-next/mongo-orm";
10
+ {{else}}
11
+ import type { DefaultModelRow } from "@prisma-next/sql-orm-client";
12
+ {{/if}}
13
+ {{/if}}
7
14
  import type { Contract } from "../../prisma/contract.d";
8
15
  import contractJson from "../../prisma/contract.json" with { type: "json" };
9
16
 
@@ -19,41 +26,50 @@ export const db = postgres<Contract>({
19
26
  });
20
27
  {{/if}}
21
28
 
22
- export type StarterUser = {
23
- id: string;
24
- email: string;
25
- name: string | null;
26
- createdAt: Date | null;
27
- };
29
+ {{#if (eq schemaPreset "basic")}}
30
+ type UserRow = DefaultModelRow<Contract, "User">;
31
+
32
+ {{#if (eq provider "mongo")}}
33
+ function toStarterUser(user: Pick<UserRow, "_id" | "email" | "name">) {
34
+ return {
35
+ id: String(user._id),
36
+ email: user.email,
37
+ name: user.name ?? null,
38
+ createdAt: null,
39
+ };
40
+ }
41
+ {{else}}
42
+ function toStarterUser(user: Pick<UserRow, "id" | "email" | "name" | "createdAt">) {
43
+ return {
44
+ id: String(user.id),
45
+ email: user.email,
46
+ name: user.name ?? null,
47
+ createdAt: user.createdAt,
48
+ };
49
+ }
50
+ {{/if}}
51
+ {{/if}}
28
52
 
29
- export async function listUsers(limit = 10): Promise<StarterUser[]> {
53
+ export async function listUsers(limit = 10) {
30
54
  {{#if (eq schemaPreset "basic")}}
31
55
  {{#if (eq provider "mongo")}}
32
- const users: StarterUser[] = [];
56
+ const users: ReturnType<typeof toStarterUser>[] = [];
33
57
 
34
58
  for await (const user of db.orm.users.select("_id", "email", "name").take(limit).all()) {
35
- users.push({
36
- id: String(user._id),
37
- email: user.email,
38
- name: user.name ?? null,
39
- createdAt: null,
40
- });
59
+ users.push(toStarterUser(user));
41
60
  }
42
61
 
43
62
  return users;
44
63
  {{else}}
45
64
  const users = await db.orm.User.select("id", "email", "name", "createdAt").take(limit).all();
46
65
 
47
- return users.map((user) => ({
48
- id: String(user.id),
49
- email: user.email,
50
- name: user.name ?? null,
51
- createdAt: user.createdAt,
52
- }));
66
+ return users.map(toStarterUser);
53
67
  {{/if}}
54
68
  {{else}}
55
69
  return [];
56
70
  {{/if}}
57
71
  }
58
72
 
73
+ export type StarterUser = Awaited<ReturnType<typeof listUsers>>[number];
74
+
59
75
  export default db;
@@ -36,6 +36,8 @@ Database helper scripts are added to `package.json`:
36
36
  - `{{runScriptCommand packageManager "db:seed"}}` - insert sample users manually
37
37
  {{/if}}
38
38
 
39
+ See `prisma-next.md` and `.agents/skills/prisma-next/SKILL.md` for provider-specific Prisma Next workflow notes.
40
+
39
41
  Node-based Prisma Next projects expect Node.js 24 LTS or newer.
40
42
  {{#if (eq schemaPreset "basic")}}
41
43
 
@@ -4,6 +4,13 @@ import mongo from "@prisma-next/mongo/runtime";
4
4
  {{else}}
5
5
  import postgres from "@prisma-next/postgres/runtime";
6
6
  {{/if}}
7
+ {{#if (eq schemaPreset "basic")}}
8
+ {{#if (eq provider "mongo")}}
9
+ import type { DefaultModelRow } from "@prisma-next/mongo-orm";
10
+ {{else}}
11
+ import type { DefaultModelRow } from "@prisma-next/sql-orm-client";
12
+ {{/if}}
13
+ {{/if}}
7
14
  import type { Contract } from "../../prisma/contract.d";
8
15
  import contractJson from "../../prisma/contract.json" with { type: "json" };
9
16
 
@@ -19,41 +26,50 @@ export const db = postgres<Contract>({
19
26
  });
20
27
  {{/if}}
21
28
 
22
- export type StarterUser = {
23
- id: string;
24
- email: string;
25
- name: string | null;
26
- createdAt: Date | null;
27
- };
29
+ {{#if (eq schemaPreset "basic")}}
30
+ type UserRow = DefaultModelRow<Contract, "User">;
31
+
32
+ {{#if (eq provider "mongo")}}
33
+ function toStarterUser(user: Pick<UserRow, "_id" | "email" | "name">) {
34
+ return {
35
+ id: String(user._id),
36
+ email: user.email,
37
+ name: user.name ?? null,
38
+ createdAt: null,
39
+ };
40
+ }
41
+ {{else}}
42
+ function toStarterUser(user: Pick<UserRow, "id" | "email" | "name" | "createdAt">) {
43
+ return {
44
+ id: String(user.id),
45
+ email: user.email,
46
+ name: user.name ?? null,
47
+ createdAt: user.createdAt,
48
+ };
49
+ }
50
+ {{/if}}
51
+ {{/if}}
28
52
 
29
- export async function listUsers(limit = 10): Promise<StarterUser[]> {
53
+ export async function listUsers(limit = 10) {
30
54
  {{#if (eq schemaPreset "basic")}}
31
55
  {{#if (eq provider "mongo")}}
32
- const users: StarterUser[] = [];
56
+ const users: ReturnType<typeof toStarterUser>[] = [];
33
57
 
34
58
  for await (const user of db.orm.users.select("_id", "email", "name").take(limit).all()) {
35
- users.push({
36
- id: String(user._id),
37
- email: user.email,
38
- name: user.name ?? null,
39
- createdAt: null,
40
- });
59
+ users.push(toStarterUser(user));
41
60
  }
42
61
 
43
62
  return users;
44
63
  {{else}}
45
64
  const users = await db.orm.User.select("id", "email", "name", "createdAt").take(limit).all();
46
65
 
47
- return users.map((user) => ({
48
- id: String(user.id),
49
- email: user.email,
50
- name: user.name ?? null,
51
- createdAt: user.createdAt,
52
- }));
66
+ return users.map(toStarterUser);
53
67
  {{/if}}
54
68
  {{else}}
55
69
  return [];
56
70
  {{/if}}
57
71
  }
58
72
 
73
+ export type StarterUser = Awaited<ReturnType<typeof listUsers>>[number];
74
+
59
75
  export default db;
@@ -35,6 +35,8 @@ Database helper scripts are added to `package.json`:
35
35
  - `{{runScriptCommand packageManager "db:seed"}}` - insert sample users manually
36
36
  {{/if}}
37
37
 
38
+ See `prisma-next.md` and `.agents/skills/prisma-next/SKILL.md` for provider-specific Prisma Next workflow notes.
39
+
38
40
  Node-based Prisma Next projects expect Node.js 24 LTS or newer.
39
41
  {{#if (eq schemaPreset "basic")}}
40
42
 
@@ -4,6 +4,13 @@ import mongo from "@prisma-next/mongo/runtime";
4
4
  {{else}}
5
5
  import postgres from "@prisma-next/postgres/runtime";
6
6
  {{/if}}
7
+ {{#if (eq schemaPreset "basic")}}
8
+ {{#if (eq provider "mongo")}}
9
+ import type { DefaultModelRow } from "@prisma-next/mongo-orm";
10
+ {{else}}
11
+ import type { DefaultModelRow } from "@prisma-next/sql-orm-client";
12
+ {{/if}}
13
+ {{/if}}
7
14
  import type { Contract } from "../../../prisma/contract.d";
8
15
  import contractJson from "../../../prisma/contract.json" with { type: "json" };
9
16
 
@@ -19,41 +26,50 @@ export const db = postgres<Contract>({
19
26
  });
20
27
  {{/if}}
21
28
 
22
- export type StarterUser = {
23
- id: string;
24
- email: string;
25
- name: string | null;
26
- createdAt: Date | null;
27
- };
29
+ {{#if (eq schemaPreset "basic")}}
30
+ type UserRow = DefaultModelRow<Contract, "User">;
31
+
32
+ {{#if (eq provider "mongo")}}
33
+ function toStarterUser(user: Pick<UserRow, "_id" | "email" | "name">) {
34
+ return {
35
+ id: String(user._id),
36
+ email: user.email,
37
+ name: user.name ?? null,
38
+ createdAt: null,
39
+ };
40
+ }
41
+ {{else}}
42
+ function toStarterUser(user: Pick<UserRow, "id" | "email" | "name" | "createdAt">) {
43
+ return {
44
+ id: String(user.id),
45
+ email: user.email,
46
+ name: user.name ?? null,
47
+ createdAt: user.createdAt,
48
+ };
49
+ }
50
+ {{/if}}
51
+ {{/if}}
28
52
 
29
- export async function listUsers(limit = 10): Promise<StarterUser[]> {
53
+ export async function listUsers(limit = 10) {
30
54
  {{#if (eq schemaPreset "basic")}}
31
55
  {{#if (eq provider "mongo")}}
32
- const users: StarterUser[] = [];
56
+ const users: ReturnType<typeof toStarterUser>[] = [];
33
57
 
34
58
  for await (const user of db.orm.users.select("_id", "email", "name").take(limit).all()) {
35
- users.push({
36
- id: String(user._id),
37
- email: user.email,
38
- name: user.name ?? null,
39
- createdAt: null,
40
- });
59
+ users.push(toStarterUser(user));
41
60
  }
42
61
 
43
62
  return users;
44
63
  {{else}}
45
64
  const users = await db.orm.User.select("id", "email", "name", "createdAt").take(limit).all();
46
65
 
47
- return users.map((user) => ({
48
- id: String(user.id),
49
- email: user.email,
50
- name: user.name ?? null,
51
- createdAt: user.createdAt,
52
- }));
66
+ return users.map(toStarterUser);
53
67
  {{/if}}
54
68
  {{else}}
55
69
  return [];
56
70
  {{/if}}
57
71
  }
58
72
 
73
+ export type StarterUser = Awaited<ReturnType<typeof listUsers>>[number];
74
+
59
75
  export default db;
@@ -35,6 +35,8 @@ Database helper scripts are added to `package.json`:
35
35
  - `{{runScriptCommand packageManager "db:seed"}}` - insert sample users manually
36
36
  {{/if}}
37
37
 
38
+ See `prisma-next.md` and `.agents/skills/prisma-next/SKILL.md` for provider-specific Prisma Next workflow notes.
39
+
38
40
  Node-based Prisma Next projects expect Node.js 24 LTS or newer.
39
41
  {{#if (eq schemaPreset "basic")}}
40
42
 
@@ -4,6 +4,13 @@ import mongo from "@prisma-next/mongo/runtime";
4
4
  {{else}}
5
5
  import postgres from "@prisma-next/postgres/runtime";
6
6
  {{/if}}
7
+ {{#if (eq schemaPreset "basic")}}
8
+ {{#if (eq provider "mongo")}}
9
+ import type { DefaultModelRow } from "@prisma-next/mongo-orm";
10
+ {{else}}
11
+ import type { DefaultModelRow } from "@prisma-next/sql-orm-client";
12
+ {{/if}}
13
+ {{/if}}
7
14
  import type { Contract } from "../../prisma/contract.d";
8
15
  import contractJson from "../../prisma/contract.json" with { type: "json" };
9
16
 
@@ -19,41 +26,50 @@ export const db = postgres<Contract>({
19
26
  });
20
27
  {{/if}}
21
28
 
22
- export type StarterUser = {
23
- id: string;
24
- email: string;
25
- name: string | null;
26
- createdAt: Date | null;
27
- };
29
+ {{#if (eq schemaPreset "basic")}}
30
+ type UserRow = DefaultModelRow<Contract, "User">;
31
+
32
+ {{#if (eq provider "mongo")}}
33
+ function toStarterUser(user: Pick<UserRow, "_id" | "email" | "name">) {
34
+ return {
35
+ id: String(user._id),
36
+ email: user.email,
37
+ name: user.name ?? null,
38
+ createdAt: null,
39
+ };
40
+ }
41
+ {{else}}
42
+ function toStarterUser(user: Pick<UserRow, "id" | "email" | "name" | "createdAt">) {
43
+ return {
44
+ id: String(user.id),
45
+ email: user.email,
46
+ name: user.name ?? null,
47
+ createdAt: user.createdAt,
48
+ };
49
+ }
50
+ {{/if}}
51
+ {{/if}}
28
52
 
29
- export async function listUsers(limit = 10): Promise<StarterUser[]> {
53
+ export async function listUsers(limit = 10) {
30
54
  {{#if (eq schemaPreset "basic")}}
31
55
  {{#if (eq provider "mongo")}}
32
- const users: StarterUser[] = [];
56
+ const users: ReturnType<typeof toStarterUser>[] = [];
33
57
 
34
58
  for await (const user of db.orm.users.select("_id", "email", "name").take(limit).all()) {
35
- users.push({
36
- id: String(user._id),
37
- email: user.email,
38
- name: user.name ?? null,
39
- createdAt: null,
40
- });
59
+ users.push(toStarterUser(user));
41
60
  }
42
61
 
43
62
  return users;
44
63
  {{else}}
45
64
  const users = await db.orm.User.select("id", "email", "name", "createdAt").take(limit).all();
46
65
 
47
- return users.map((user) => ({
48
- id: String(user.id),
49
- email: user.email,
50
- name: user.name ?? null,
51
- createdAt: user.createdAt,
52
- }));
66
+ return users.map(toStarterUser);
53
67
  {{/if}}
54
68
  {{else}}
55
69
  return [];
56
70
  {{/if}}
57
71
  }
58
72
 
73
+ export type StarterUser = Awaited<ReturnType<typeof listUsers>>[number];
74
+
59
75
  export default db;
@@ -27,6 +27,8 @@ Generated by `create-prisma` with the Turborepo template.
27
27
  - `{{runScriptCommand packageManager "db:seed"}}` - insert sample users manually in `packages/db`
28
28
  {{/if}}
29
29
 
30
+ See `packages/db/prisma-next.md` and `packages/db/.agents/skills/prisma-next/SKILL.md` for provider-specific Prisma Next workflow notes.
31
+
30
32
  ## Prisma Next
31
33
 
32
34
  Prisma Next is scaffolded inside `packages/db`:
@@ -22,9 +22,12 @@
22
22
  "contract:emit": "{{runScriptInDirectoryCommand packageManager "packages/db" "contract:emit"}}",
23
23
  "db:init": "{{runScriptInDirectoryCommand packageManager "packages/db" "db:init"}}",
24
24
  "db:update": "{{runScriptInDirectoryCommand packageManager "packages/db" "db:update"}}",
25
+ "db:verify": "{{runScriptInDirectoryCommand packageManager "packages/db" "db:verify"}}",
25
26
  "db:seed": "{{runScriptInDirectoryCommand packageManager "packages/db" "db:seed"}}",
26
27
  "migration:plan": "{{runScriptInDirectoryCommandWithArgsPassthrough packageManager "packages/db" "migration:plan"}}",
27
- "migration:apply": "{{runScriptInDirectoryCommand packageManager "packages/db" "migration:apply"}}"
28
+ "migration:apply": "{{runScriptInDirectoryCommand packageManager "packages/db" "migration:apply"}}",
29
+ "migration:status": "{{runScriptInDirectoryCommand packageManager "packages/db" "migration:status"}}",
30
+ "migration:show": "{{runScriptInDirectoryCommandWithArgsPassthrough packageManager "packages/db" "migration:show"}}"
28
31
  },
29
32
  "devDependencies": {
30
33
  "turbo": "^2.5.6"
@@ -10,6 +10,13 @@ import mongo from "@prisma-next/mongo/runtime";
10
10
  {{else}}
11
11
  import postgres from "@prisma-next/postgres/runtime";
12
12
  {{/if}}
13
+ {{#if (eq schemaPreset "basic")}}
14
+ {{#if (eq provider "mongo")}}
15
+ import type { DefaultModelRow } from "@prisma-next/mongo-orm";
16
+ {{else}}
17
+ import type { DefaultModelRow } from "@prisma-next/sql-orm-client";
18
+ {{/if}}
19
+ {{/if}}
13
20
  import type { Contract } from "../prisma/contract.d";
14
21
  import contractJson from "../prisma/contract.json" with { type: "json" };
15
22
 
@@ -30,41 +37,50 @@ export const db = postgres<Contract>({
30
37
  });
31
38
  {{/if}}
32
39
 
33
- export type StarterUser = {
34
- id: string;
35
- email: string;
36
- name: string | null;
37
- createdAt: Date | null;
38
- };
40
+ {{#if (eq schemaPreset "basic")}}
41
+ type UserRow = DefaultModelRow<Contract, "User">;
42
+
43
+ {{#if (eq provider "mongo")}}
44
+ function toStarterUser(user: Pick<UserRow, "_id" | "email" | "name">) {
45
+ return {
46
+ id: String(user._id),
47
+ email: user.email,
48
+ name: user.name ?? null,
49
+ createdAt: null,
50
+ };
51
+ }
52
+ {{else}}
53
+ function toStarterUser(user: Pick<UserRow, "id" | "email" | "name" | "createdAt">) {
54
+ return {
55
+ id: String(user.id),
56
+ email: user.email,
57
+ name: user.name ?? null,
58
+ createdAt: user.createdAt,
59
+ };
60
+ }
61
+ {{/if}}
62
+ {{/if}}
39
63
 
40
- export async function listUsers(limit = 10): Promise<StarterUser[]> {
64
+ export async function listUsers(limit = 10) {
41
65
  {{#if (eq schemaPreset "basic")}}
42
66
  {{#if (eq provider "mongo")}}
43
- const users: StarterUser[] = [];
67
+ const users: ReturnType<typeof toStarterUser>[] = [];
44
68
 
45
69
  for await (const user of db.orm.users.select("_id", "email", "name").take(limit).all()) {
46
- users.push({
47
- id: String(user._id),
48
- email: user.email,
49
- name: user.name ?? null,
50
- createdAt: null,
51
- });
70
+ users.push(toStarterUser(user));
52
71
  }
53
72
 
54
73
  return users;
55
74
  {{else}}
56
75
  const users = await db.orm.User.select("id", "email", "name", "createdAt").take(limit).all();
57
76
 
58
- return users.map((user) => ({
59
- id: String(user.id),
60
- email: user.email,
61
- name: user.name ?? null,
62
- createdAt: user.createdAt,
63
- }));
77
+ return users.map(toStarterUser);
64
78
  {{/if}}
65
79
  {{else}}
66
80
  return [];
67
81
  {{/if}}
68
82
  }
69
83
 
84
+ export type StarterUser = Awaited<ReturnType<typeof listUsers>>[number];
85
+
70
86
  export default db;
@@ -21,6 +21,9 @@
21
21
  "db:update": {
22
22
  "cache": false
23
23
  },
24
+ "db:verify": {
25
+ "cache": false
26
+ },
24
27
  "db:seed": {
25
28
  "cache": false
26
29
  },
@@ -29,6 +32,12 @@
29
32
  },
30
33
  "migration:apply": {
31
34
  "cache": false
35
+ },
36
+ "migration:status": {
37
+ "cache": false
38
+ },
39
+ "migration:show": {
40
+ "cache": false
32
41
  }
33
42
  }
34
43
  }