create-prisma 0.4.2-next.37.104.1 → 0.4.2-next.37.106.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/dist/cli.mjs +1 -1
- package/dist/{create-BeFhatOc.mjs → create-DNd0H1pd.mjs} +21 -15
- package/dist/index.mjs +2 -2
- package/package.json +2 -2
- package/templates/create/_shared/{prisma → src/prisma}/seed.ts.hbs +1 -13
- package/templates/create/{hono/src/lib/prisma.ts.hbs → _shared/src/prisma/users.ts.hbs} +3 -20
- package/templates/create/astro/README.md.hbs +4 -3
- package/templates/create/astro/src/pages/api/users.ts.hbs +1 -2
- package/templates/create/astro/src/pages/index.astro.hbs +2 -2
- package/templates/create/elysia/README.md.hbs +4 -3
- package/templates/create/elysia/src/index.ts.hbs +1 -1
- package/templates/create/hono/README.md.hbs +4 -3
- package/templates/create/hono/src/index.ts.hbs +1 -1
- package/templates/create/minimal/README.md.hbs +4 -3
- package/templates/create/minimal/src/index.ts.hbs +1 -1
- package/templates/create/minimal/tsconfig.json +1 -1
- package/templates/create/nest/README.md.hbs +4 -3
- package/templates/create/nest/src/prisma.service.ts.hbs +1 -1
- package/templates/create/next/README.md.hbs +4 -3
- package/templates/create/next/src/app/page.tsx.hbs +2 -2
- package/templates/create/nuxt/README.md.hbs +4 -3
- package/templates/create/nuxt/app/pages/index.vue.hbs +1 -1
- package/templates/create/nuxt/server/api/users.get.ts.hbs +1 -2
- package/templates/create/svelte/README.md.hbs +4 -3
- package/templates/create/svelte/src/routes/+page.server.ts.hbs +1 -2
- package/templates/create/svelte/src/routes/+page.svelte.hbs +1 -1
- package/templates/create/tanstack-start/README.md.hbs +5 -4
- package/templates/create/tanstack-start/src/routes/index.tsx.hbs +2 -2
- package/templates/create/tanstack-start/tsconfig.json +1 -1
- package/templates/create/astro/src/lib/prisma.ts.hbs +0 -73
- package/templates/create/elysia/src/lib/prisma.ts.hbs +0 -73
- package/templates/create/minimal/src/lib/prisma.ts.hbs +0 -73
- package/templates/create/nest/src/lib/prisma.ts.hbs +0 -73
- package/templates/create/next/src/lib/prisma.ts.hbs +0 -73
- package/templates/create/nuxt/server/utils/prisma.ts.hbs +0 -73
- package/templates/create/svelte/src/lib/server/prisma.ts.hbs +0 -73
- package/templates/create/tanstack-start/src/lib/prisma.server.ts.hbs +0 -73
package/dist/cli.mjs
CHANGED
|
@@ -131,7 +131,7 @@ async function getAnonymousId() {
|
|
|
131
131
|
}
|
|
132
132
|
function getCommonProperties() {
|
|
133
133
|
return {
|
|
134
|
-
"cli-version": "0.4.2-next.37.
|
|
134
|
+
"cli-version": "0.4.2-next.37.106.1",
|
|
135
135
|
"node-version": process.version,
|
|
136
136
|
platform: process.platform,
|
|
137
137
|
arch: process.arch
|
|
@@ -657,7 +657,7 @@ function getPrismaNextScriptMap(packageManager) {
|
|
|
657
657
|
"db:init": `${prismaNextCli} db init`,
|
|
658
658
|
"db:update": `${prismaNextCli} db update`,
|
|
659
659
|
"db:verify": `${prismaNextCli} db verify`,
|
|
660
|
-
"db:seed": "deno run -A --env-file=.env prisma/seed.ts",
|
|
660
|
+
"db:seed": "deno run -A --env-file=.env src/prisma/seed.ts",
|
|
661
661
|
"migration:plan": `${prismaNextCli} migration plan`,
|
|
662
662
|
migrate: `${prismaNextCli} migrate`,
|
|
663
663
|
"migration:status": `${prismaNextCli} migration status`,
|
|
@@ -671,7 +671,7 @@ function getPrismaNextScriptMap(packageManager) {
|
|
|
671
671
|
"db:init": `${prismaNextCli} db init`,
|
|
672
672
|
"db:update": `${prismaNextCli} db update`,
|
|
673
673
|
"db:verify": `${prismaNextCli} db verify`,
|
|
674
|
-
"db:seed": "bun prisma/seed.ts",
|
|
674
|
+
"db:seed": "bun src/prisma/seed.ts",
|
|
675
675
|
"migration:plan": `${prismaNextCli} migration plan`,
|
|
676
676
|
migrate: `${prismaNextCli} migrate`,
|
|
677
677
|
"migration:status": `${prismaNextCli} migration status`,
|
|
@@ -683,7 +683,7 @@ function getPrismaNextScriptMap(packageManager) {
|
|
|
683
683
|
"db:init": "prisma-next db init",
|
|
684
684
|
"db:update": "prisma-next db update",
|
|
685
685
|
"db:verify": "prisma-next db verify",
|
|
686
|
-
"db:seed": "tsx prisma/seed.ts",
|
|
686
|
+
"db:seed": "tsx src/prisma/seed.ts",
|
|
687
687
|
"migration:plan": "prisma-next migration plan",
|
|
688
688
|
migrate: "prisma-next migrate",
|
|
689
689
|
"migration:status": "prisma-next migration status",
|
|
@@ -866,7 +866,7 @@ const DEFAULT_AUTHORING = "psl";
|
|
|
866
866
|
const DEFAULT_INSTALL = true;
|
|
867
867
|
const DEFAULT_EMIT = true;
|
|
868
868
|
const DEFAULT_INTERACTIVE_PRISMA_POSTGRES = true;
|
|
869
|
-
const DEFAULT_AUTOMATED_PRISMA_POSTGRES =
|
|
869
|
+
const DEFAULT_AUTOMATED_PRISMA_POSTGRES = true;
|
|
870
870
|
const MONGO_MEMORY_SERVER_SCRIPT = `import { spawn } from "node:child_process";
|
|
871
871
|
import { closeSync, existsSync, mkdirSync, openSync, readFileSync, rmSync, writeFileSync } from "node:fs";
|
|
872
872
|
import path from "node:path";
|
|
@@ -1063,17 +1063,12 @@ function getMongoMemoryScripts(packageManager) {
|
|
|
1063
1063
|
}
|
|
1064
1064
|
}
|
|
1065
1065
|
const requiredPrismaFileGroups = [
|
|
1066
|
-
["prisma/contract.prisma", "prisma/contract.ts"],
|
|
1066
|
+
["src/prisma/contract.prisma", "src/prisma/contract.ts"],
|
|
1067
1067
|
["prisma-next.config.ts"],
|
|
1068
|
-
[
|
|
1069
|
-
"src/lib/prisma.ts",
|
|
1070
|
-
"src/lib/prisma.server.ts",
|
|
1071
|
-
"src/lib/server/prisma.ts",
|
|
1072
|
-
"server/utils/prisma.ts"
|
|
1073
|
-
]
|
|
1068
|
+
["src/prisma/db.ts"]
|
|
1074
1069
|
];
|
|
1075
1070
|
function getContractPath(authoring) {
|
|
1076
|
-
return `prisma/contract${authoring === "typescript" ? ".ts" : ".prisma"}`;
|
|
1071
|
+
return `src/prisma/contract${authoring === "typescript" ? ".ts" : ".prisma"}`;
|
|
1077
1072
|
}
|
|
1078
1073
|
async function promptForDatabaseProvider() {
|
|
1079
1074
|
const databaseProvider = await select({
|
|
@@ -1128,6 +1123,12 @@ async function promptForPrismaPostgres() {
|
|
|
1128
1123
|
}
|
|
1129
1124
|
return Boolean(shouldUsePrismaPostgres);
|
|
1130
1125
|
}
|
|
1126
|
+
async function resolvePrismaPostgresChoice(options) {
|
|
1127
|
+
const { explicitChoice, databaseProvider, databaseUrl, useDefaults } = options;
|
|
1128
|
+
if (explicitChoice !== void 0) return explicitChoice;
|
|
1129
|
+
if (databaseProvider !== "postgres" || databaseUrl) return false;
|
|
1130
|
+
return useDefaults ? DEFAULT_AUTOMATED_PRISMA_POSTGRES : await promptForPrismaPostgres();
|
|
1131
|
+
}
|
|
1131
1132
|
function getPackageManagerHint(option, detected) {
|
|
1132
1133
|
const hint = {
|
|
1133
1134
|
npm: "Node.js default",
|
|
@@ -1211,7 +1212,12 @@ async function collectPrismaSetupContext(input, options = {}) {
|
|
|
1211
1212
|
const databaseProvider = input.provider ?? (useDefaults ? DEFAULT_DATABASE_PROVIDER : await promptForDatabaseProvider());
|
|
1212
1213
|
if (!databaseProvider) return;
|
|
1213
1214
|
const databaseUrl = input.databaseUrl;
|
|
1214
|
-
const shouldUsePrismaPostgres =
|
|
1215
|
+
const shouldUsePrismaPostgres = await resolvePrismaPostgresChoice({
|
|
1216
|
+
explicitChoice: input.prismaPostgres,
|
|
1217
|
+
databaseProvider,
|
|
1218
|
+
databaseUrl,
|
|
1219
|
+
useDefaults
|
|
1220
|
+
});
|
|
1215
1221
|
if (shouldUsePrismaPostgres === void 0) return;
|
|
1216
1222
|
if (shouldUsePrismaPostgres && databaseProvider !== "postgres") {
|
|
1217
1223
|
cancel("--prisma-postgres is only supported with --provider postgres.");
|
|
@@ -1580,7 +1586,7 @@ function buildNextStepsForContext(opts) {
|
|
|
1580
1586
|
});
|
|
1581
1587
|
nextSteps.push({
|
|
1582
1588
|
command: getRunScriptCommand(context.packageManager, "db:seed"),
|
|
1583
|
-
description: "Insert the sample users from prisma/seed.ts."
|
|
1589
|
+
description: "Insert the sample users from src/prisma/seed.ts."
|
|
1584
1590
|
});
|
|
1585
1591
|
if (options.includeDevNextStep) nextSteps.push({
|
|
1586
1592
|
command: getRunScriptCommand(context.packageManager, "dev"),
|
package/dist/index.mjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { a as DatabaseProviderSchema, i as CreateTemplateSchema, n as AuthoringStyleSchema, o as DatabaseUrlSchema, r as CreateCommandInputSchema, s as PackageManagerSchema, t as runCreateCommand } from "./create-
|
|
2
|
+
import { a as DatabaseProviderSchema, i as CreateTemplateSchema, n as AuthoringStyleSchema, o as DatabaseUrlSchema, r as CreateCommandInputSchema, s as PackageManagerSchema, t as runCreateCommand } from "./create-DNd0H1pd.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.
|
|
7
|
+
const CLI_VERSION = "0.4.2-next.37.106.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.
|
|
3
|
+
"version": "0.4.2-next.37.106.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",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"dev": "tsdown --watch",
|
|
38
38
|
"start": "bun run ./dist/cli.mjs",
|
|
39
39
|
"test": "bun run test:unit && bun run test:e2e",
|
|
40
|
-
"test:unit": "bun test ./tests/dependencies.test.ts ./tests/install.test.ts ./tests/telemetry.test.ts",
|
|
40
|
+
"test:unit": "bun test ./tests/dependencies.test.ts ./tests/install.test.ts ./tests/setup-prisma.test.ts ./tests/telemetry.test.ts",
|
|
41
41
|
"test:e2e": "bun test --timeout 180000 ./tests/e2e/create-prisma.e2e.test.ts",
|
|
42
42
|
"check": "bun run format:check && bun run lint",
|
|
43
43
|
"lint": "oxlint . --deny-warnings",
|
|
@@ -1,19 +1,7 @@
|
|
|
1
1
|
{{#if (requiresDotenvConfigImport packageManager)}}
|
|
2
2
|
import "dotenv/config";
|
|
3
3
|
{{/if}}
|
|
4
|
-
{{#if (eq
|
|
5
|
-
import { db } from "../server/utils/prisma{{#if (eq packageManager "deno")}}.ts{{/if}}";
|
|
6
|
-
{{else}}
|
|
7
|
-
{{#if (eq template "svelte")}}
|
|
8
|
-
import { db } from "../src/lib/server/prisma{{#if (eq packageManager "deno")}}.ts{{/if}}";
|
|
9
|
-
{{else}}
|
|
10
|
-
{{#if (eq template "tanstack-start")}}
|
|
11
|
-
import { db } from "../src/lib/prisma.server{{#if (eq packageManager "deno")}}.ts{{/if}}";
|
|
12
|
-
{{else}}
|
|
13
|
-
import { db } from "../src/lib/prisma{{#if (eq packageManager "deno")}}.ts{{/if}}";
|
|
14
|
-
{{/if}}
|
|
15
|
-
{{/if}}
|
|
16
|
-
{{/if}}
|
|
4
|
+
import { db } from "./db{{#if (eq packageManager "deno")}}.ts{{/if}}";
|
|
17
5
|
|
|
18
6
|
const seedUsers = [
|
|
19
7
|
{ email: "alice@prisma.io", username: "alice", name: "Alice" },
|
|
@@ -1,9 +1,5 @@
|
|
|
1
1
|
import "dotenv/config";
|
|
2
|
-
{{#if (eq
|
|
3
|
-
import mongo from "@prisma-next/mongo/runtime";
|
|
4
|
-
{{else}}
|
|
5
|
-
import postgres from "@prisma-next/postgres/runtime";
|
|
6
|
-
{{/if}}
|
|
2
|
+
import { db } from "./db{{#if (eq packageManager "deno")}}.ts{{/if}}";
|
|
7
3
|
|
|
8
4
|
{{#if (eq provider "mongo")}}
|
|
9
5
|
import type { DefaultModelRow } from "@prisma-next/mongo-orm";
|
|
@@ -11,20 +7,9 @@ import type { DefaultModelRow } from "@prisma-next/mongo-orm";
|
|
|
11
7
|
import type { DefaultModelRow } from "@prisma-next/sql-orm-client";
|
|
12
8
|
{{/if}}
|
|
13
9
|
|
|
14
|
-
import type { Contract } from "
|
|
15
|
-
import contractJson from "../../prisma/contract.json" with { type: "json" };
|
|
10
|
+
import type { Contract } from "./contract.d";
|
|
16
11
|
|
|
17
|
-
{
|
|
18
|
-
export const db = mongo<Contract>({
|
|
19
|
-
contractJson,
|
|
20
|
-
url: process.env["DATABASE_URL"]!,
|
|
21
|
-
});
|
|
22
|
-
{{else}}
|
|
23
|
-
export const db = postgres<Contract>({
|
|
24
|
-
contractJson,
|
|
25
|
-
url: process.env["DATABASE_URL"]!,
|
|
26
|
-
});
|
|
27
|
-
{{/if}}
|
|
12
|
+
export { db };
|
|
28
13
|
|
|
29
14
|
type UserRow = DefaultModelRow<Contract, "User">;
|
|
30
15
|
|
|
@@ -69,5 +54,3 @@ export async function listUsers(limit = 10) {
|
|
|
69
54
|
}
|
|
70
55
|
|
|
71
56
|
export type StarterUser = Awaited<ReturnType<typeof listUsers>>[number];
|
|
72
|
-
|
|
73
|
-
export default db;
|
|
@@ -13,9 +13,11 @@ Generated by `create-prisma` with the Astro template.
|
|
|
13
13
|
|
|
14
14
|
Prisma Next setup is scaffolded in:
|
|
15
15
|
|
|
16
|
-
- `prisma/contract{{#if (eq authoring "typescript")}}.ts{{else}}.prisma{{/if}}`
|
|
16
|
+
- `src/prisma/contract{{#if (eq authoring "typescript")}}.ts{{else}}.prisma{{/if}}`
|
|
17
17
|
- `prisma-next.config.ts`
|
|
18
|
-
- `src/
|
|
18
|
+
- `src/prisma/db.ts`
|
|
19
|
+
- `src/prisma/users.ts`
|
|
20
|
+
- `src/prisma/seed.ts`
|
|
19
21
|
- `src/pages/api/users.ts`
|
|
20
22
|
|
|
21
23
|
Database helper scripts are added to `package.json`:
|
|
@@ -42,4 +44,3 @@ The Astro Vite dev server also auto-emits Prisma Next contract artifacts when th
|
|
|
42
44
|
Node-based Prisma Next projects expect Node.js 24 LTS or newer.
|
|
43
45
|
|
|
44
46
|
The starter page queries a basic `User` model in `src/pages/index.astro`, and `src/pages/api/users.ts` shows an Astro API route backed by the same Prisma Next helper.
|
|
45
|
-
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { APIRoute } from "astro";
|
|
2
2
|
|
|
3
|
-
import { listUsers } from "../../
|
|
3
|
+
import { listUsers } from "../../prisma/users";
|
|
4
4
|
|
|
5
5
|
export const GET: APIRoute = async () => {
|
|
6
6
|
const users = await listUsers(10).catch((error) => {
|
|
@@ -23,4 +23,3 @@ export const GET: APIRoute = async () => {
|
|
|
23
23
|
},
|
|
24
24
|
});
|
|
25
25
|
};
|
|
26
|
-
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
|
|
3
|
-
import { listUsers } from "../
|
|
3
|
+
import { listUsers } from "../prisma/users";
|
|
4
4
|
|
|
5
5
|
const formatter = new Intl.DateTimeFormat("en", {
|
|
6
6
|
dateStyle: "medium",
|
|
@@ -27,7 +27,7 @@ const users = await listUsers(10).catch(() => undefined);
|
|
|
27
27
|
<h1>Users from your database, loaded on the server.</h1>
|
|
28
28
|
<p class="lede">
|
|
29
29
|
This page reads from <code>src/pages/index.astro</code> using the Prisma Next helper in
|
|
30
|
-
<code>src/
|
|
30
|
+
<code>src/prisma/users.ts</code>. An Astro API route is also scaffolded in
|
|
31
31
|
<code>src/pages/api/users.ts</code>.
|
|
32
32
|
</p>
|
|
33
33
|
</div>
|
|
@@ -12,9 +12,11 @@ Generated by `create-prisma` with the Elysia template.
|
|
|
12
12
|
|
|
13
13
|
Prisma Next setup is scaffolded in:
|
|
14
14
|
|
|
15
|
-
- `prisma/contract{{#if (eq authoring "typescript")}}.ts{{else}}.prisma{{/if}}`
|
|
15
|
+
- `src/prisma/contract{{#if (eq authoring "typescript")}}.ts{{else}}.prisma{{/if}}`
|
|
16
16
|
- `prisma-next.config.ts`
|
|
17
|
-
- `src/
|
|
17
|
+
- `src/prisma/db.ts`
|
|
18
|
+
- `src/prisma/users.ts`
|
|
19
|
+
- `src/prisma/seed.ts`
|
|
18
20
|
|
|
19
21
|
Database helper scripts are added to `package.json`:
|
|
20
22
|
|
|
@@ -39,4 +41,3 @@ For provider-specific Prisma Next reference docs, see `prisma-next.md`. Prisma N
|
|
|
39
41
|
Node-based Prisma Next projects expect Node.js 24 LTS or newer.
|
|
40
42
|
|
|
41
43
|
The template includes a basic `User` model and a sample `GET /users` endpoint.
|
|
42
|
-
|
|
@@ -7,7 +7,7 @@ import { node } from "@elysiajs/node";
|
|
|
7
7
|
{{/if}}
|
|
8
8
|
import { Elysia } from "elysia";
|
|
9
9
|
|
|
10
|
-
import { listUsers } from "./
|
|
10
|
+
import { listUsers } from "./prisma/users{{#if (eq packageManager "deno")}}.ts{{/if}}";
|
|
11
11
|
|
|
12
12
|
const rawPort = ({{#if (eq packageManager "deno")}}Deno.env.get("PORT"){{else}}process.env.PORT{{/if}} ?? "").trim();
|
|
13
13
|
const parsedPort = rawPort.length > 0 ? Number(rawPort) : Number.NaN;
|
|
@@ -12,9 +12,11 @@ Generated by `create-prisma` with the Hono template.
|
|
|
12
12
|
|
|
13
13
|
Prisma Next setup is scaffolded in:
|
|
14
14
|
|
|
15
|
-
- `prisma/contract{{#if (eq authoring "typescript")}}.ts{{else}}.prisma{{/if}}`
|
|
15
|
+
- `src/prisma/contract{{#if (eq authoring "typescript")}}.ts{{else}}.prisma{{/if}}`
|
|
16
16
|
- `prisma-next.config.ts`
|
|
17
|
-
- `src/
|
|
17
|
+
- `src/prisma/db.ts`
|
|
18
|
+
- `src/prisma/users.ts`
|
|
19
|
+
- `src/prisma/seed.ts`
|
|
18
20
|
|
|
19
21
|
Database helper scripts are added to `package.json`:
|
|
20
22
|
|
|
@@ -39,4 +41,3 @@ For provider-specific Prisma Next reference docs, see `prisma-next.md`. Prisma N
|
|
|
39
41
|
Node-based Prisma Next projects expect Node.js 24 LTS or newer.
|
|
40
42
|
|
|
41
43
|
The template includes a basic `User` model and a sample `GET /users` endpoint.
|
|
42
|
-
|
|
@@ -4,7 +4,7 @@ import "dotenv/config";
|
|
|
4
4
|
import { serve } from "@hono/node-server";
|
|
5
5
|
import { Hono } from "hono";
|
|
6
6
|
|
|
7
|
-
import { listUsers } from "./
|
|
7
|
+
import { listUsers } from "./prisma/users{{#if (eq packageManager "deno")}}.ts{{/if}}";
|
|
8
8
|
|
|
9
9
|
const app = new Hono();
|
|
10
10
|
|
|
@@ -10,10 +10,11 @@ Generated by `create-prisma` with the Minimal template.
|
|
|
10
10
|
|
|
11
11
|
Prisma Next setup is scaffolded in:
|
|
12
12
|
|
|
13
|
-
- `prisma/contract{{#if (eq authoring "typescript")}}.ts{{else}}.prisma{{/if}}`
|
|
13
|
+
- `src/prisma/contract{{#if (eq authoring "typescript")}}.ts{{else}}.prisma{{/if}}`
|
|
14
14
|
- `prisma-next.config.ts`
|
|
15
|
-
- `prisma/db.ts`
|
|
16
|
-
- `src/
|
|
15
|
+
- `src/prisma/db.ts`
|
|
16
|
+
- `src/prisma/users.ts`
|
|
17
|
+
- `src/prisma/seed.ts`
|
|
17
18
|
|
|
18
19
|
Database helper scripts are added to `package.json`:
|
|
19
20
|
|
|
@@ -12,9 +12,11 @@ Generated by `create-prisma` with the NestJS template.
|
|
|
12
12
|
|
|
13
13
|
Prisma Next setup is scaffolded in:
|
|
14
14
|
|
|
15
|
-
- `prisma/contract{{#if (eq authoring "typescript")}}.ts{{else}}.prisma{{/if}}`
|
|
15
|
+
- `src/prisma/contract{{#if (eq authoring "typescript")}}.ts{{else}}.prisma{{/if}}`
|
|
16
16
|
- `prisma-next.config.ts`
|
|
17
|
-
- `src/
|
|
17
|
+
- `src/prisma/db.ts`
|
|
18
|
+
- `src/prisma/users.ts`
|
|
19
|
+
- `src/prisma/seed.ts`
|
|
18
20
|
- `src/prisma.service.ts`
|
|
19
21
|
|
|
20
22
|
Database helper scripts are added to `package.json`:
|
|
@@ -40,4 +42,3 @@ For provider-specific Prisma Next reference docs, see `prisma-next.md`. Prisma N
|
|
|
40
42
|
Node-based Prisma Next projects expect Node.js 24 LTS or newer.
|
|
41
43
|
|
|
42
44
|
The template includes a basic `User` model and a sample `GET /users` endpoint.
|
|
43
|
-
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Injectable } from "@nestjs/common";
|
|
2
|
-
import { db, listUsers, type StarterUser } from "./
|
|
2
|
+
import { db, listUsers, type StarterUser } from "./prisma/users{{#if (eq packageManager "deno")}}.ts{{/if}}";
|
|
3
3
|
|
|
4
4
|
@Injectable()
|
|
5
5
|
export class PrismaService {
|
|
@@ -12,9 +12,11 @@ Generated by `create-prisma` with the Next.js template.
|
|
|
12
12
|
|
|
13
13
|
Prisma Next setup is scaffolded in:
|
|
14
14
|
|
|
15
|
-
- `prisma/contract{{#if (eq authoring "typescript")}}.ts{{else}}.prisma{{/if}}`
|
|
15
|
+
- `src/prisma/contract{{#if (eq authoring "typescript")}}.ts{{else}}.prisma{{/if}}`
|
|
16
16
|
- `prisma-next.config.ts`
|
|
17
|
-
- `src/
|
|
17
|
+
- `src/prisma/db.ts`
|
|
18
|
+
- `src/prisma/users.ts`
|
|
19
|
+
- `src/prisma/seed.ts`
|
|
18
20
|
|
|
19
21
|
Database helper scripts are added to `package.json`:
|
|
20
22
|
|
|
@@ -39,4 +41,3 @@ For provider-specific Prisma Next reference docs, see `prisma-next.md`. Prisma N
|
|
|
39
41
|
Node-based Prisma Next projects expect Node.js 24 LTS or newer.
|
|
40
42
|
|
|
41
43
|
The starter page in `src/app/page.tsx` reads from a basic `User` model so you can verify queries quickly after you initialize and apply your schema.
|
|
42
|
-
|
|
@@ -5,7 +5,7 @@ export const dynamic = "force-dynamic";
|
|
|
5
5
|
|
|
6
6
|
export default async function Home() {
|
|
7
7
|
|
|
8
|
-
const { listUsers } = await import("../
|
|
8
|
+
const { listUsers } = await import("../prisma/users");
|
|
9
9
|
const formatter = new Intl.DateTimeFormat("en", {
|
|
10
10
|
dateStyle: "medium",
|
|
11
11
|
timeStyle: "short",
|
|
@@ -20,7 +20,7 @@ export default async function Home() {
|
|
|
20
20
|
<h1>Users from your database, loaded on the server.</h1>
|
|
21
21
|
<p className="lede">
|
|
22
22
|
This page reads from <code>src/app/page.tsx</code> using the Prisma Next helper in{" "}
|
|
23
|
-
<code>src/
|
|
23
|
+
<code>src/prisma/users.ts</code>.
|
|
24
24
|
</p>
|
|
25
25
|
</div>
|
|
26
26
|
|
|
@@ -13,9 +13,11 @@ Generated by `create-prisma` with the Nuxt template.
|
|
|
13
13
|
|
|
14
14
|
Prisma Next setup is scaffolded in:
|
|
15
15
|
|
|
16
|
-
- `prisma/contract{{#if (eq authoring "typescript")}}.ts{{else}}.prisma{{/if}}`
|
|
16
|
+
- `src/prisma/contract{{#if (eq authoring "typescript")}}.ts{{else}}.prisma{{/if}}`
|
|
17
17
|
- `prisma-next.config.ts`
|
|
18
|
-
- `
|
|
18
|
+
- `src/prisma/db.ts`
|
|
19
|
+
- `src/prisma/users.ts`
|
|
20
|
+
- `src/prisma/seed.ts`
|
|
19
21
|
- `server/api/users.get.ts`
|
|
20
22
|
|
|
21
23
|
Database helper scripts are added to `package.json`:
|
|
@@ -42,4 +44,3 @@ The Nuxt Vite dev server also auto-emits Prisma Next contract artifacts when the
|
|
|
42
44
|
Node-based Prisma Next projects expect Node.js 24 LTS or newer.
|
|
43
45
|
|
|
44
46
|
The starter page in `app/pages/index.vue` fetches users from `server/api/users.get.ts` after you initialize and apply your schema.
|
|
45
|
-
|
|
@@ -37,7 +37,7 @@ function formatCreatedAt(value: string): string {
|
|
|
37
37
|
<h1>Users from your database, loaded through Nitro.</h1>
|
|
38
38
|
<p class="lede">
|
|
39
39
|
This page fetches <code>/api/users</code> from <code>server/api/users.get.ts</code> using
|
|
40
|
-
the Prisma Next helper in <code>
|
|
40
|
+
the Prisma Next helper in <code>src/prisma/users.ts</code>.
|
|
41
41
|
</p>
|
|
42
42
|
</div>
|
|
43
43
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { listUsers } from "
|
|
1
|
+
import { listUsers } from "../../src/prisma/users";
|
|
2
2
|
|
|
3
3
|
export default defineEventHandler(async () => {
|
|
4
4
|
const users = await listUsers(10)
|
|
@@ -22,4 +22,3 @@ export default defineEventHandler(async () => {
|
|
|
22
22
|
|
|
23
23
|
return { users };
|
|
24
24
|
});
|
|
25
|
-
|
|
@@ -13,9 +13,11 @@ Generated by `create-prisma` with the SvelteKit template.
|
|
|
13
13
|
|
|
14
14
|
Prisma Next setup is scaffolded in:
|
|
15
15
|
|
|
16
|
-
- `prisma/contract{{#if (eq authoring "typescript")}}.ts{{else}}.prisma{{/if}}`
|
|
16
|
+
- `src/prisma/contract{{#if (eq authoring "typescript")}}.ts{{else}}.prisma{{/if}}`
|
|
17
17
|
- `prisma-next.config.ts`
|
|
18
|
-
- `src/
|
|
18
|
+
- `src/prisma/db.ts`
|
|
19
|
+
- `src/prisma/users.ts`
|
|
20
|
+
- `src/prisma/seed.ts`
|
|
19
21
|
|
|
20
22
|
Database helper scripts are added to `package.json`:
|
|
21
23
|
|
|
@@ -41,4 +43,3 @@ The SvelteKit Vite dev server also auto-emits Prisma Next contract artifacts whe
|
|
|
41
43
|
Node-based Prisma Next projects expect Node.js 24 LTS or newer.
|
|
42
44
|
|
|
43
45
|
The starter page loads users in `+page.server.ts` and renders them in `+page.svelte` after you initialize and apply your schema.
|
|
44
|
-
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { PageServerLoad } from "./$types";
|
|
2
2
|
|
|
3
|
-
import { listUsers } from "
|
|
3
|
+
import { listUsers } from "../prisma/users";
|
|
4
4
|
|
|
5
5
|
export const load: PageServerLoad = async () => {
|
|
6
6
|
const users = await listUsers(10)
|
|
@@ -14,4 +14,3 @@ export const load: PageServerLoad = async () => {
|
|
|
14
14
|
|
|
15
15
|
return { users };
|
|
16
16
|
};
|
|
17
|
-
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
<h1>Users from your database, loaded on the server.</h1>
|
|
22
22
|
<p class="lede">
|
|
23
23
|
This page reads from <code>+page.server.ts</code> using the Prisma Next helper in
|
|
24
|
-
<code>src/
|
|
24
|
+
<code>src/prisma/users.ts</code>.
|
|
25
25
|
</p>
|
|
26
26
|
</div>
|
|
27
27
|
|
|
@@ -13,9 +13,11 @@ Generated by `create-prisma` with the TanStack Start template.
|
|
|
13
13
|
|
|
14
14
|
Prisma Next setup is scaffolded in:
|
|
15
15
|
|
|
16
|
-
- `prisma/contract{{#if (eq authoring "typescript")}}.ts{{else}}.prisma{{/if}}`
|
|
16
|
+
- `src/prisma/contract{{#if (eq authoring "typescript")}}.ts{{else}}.prisma{{/if}}`
|
|
17
17
|
- `prisma-next.config.ts`
|
|
18
|
-
- `src/
|
|
18
|
+
- `src/prisma/db.ts`
|
|
19
|
+
- `src/prisma/users.ts`
|
|
20
|
+
- `src/prisma/seed.ts`
|
|
19
21
|
|
|
20
22
|
Database helper scripts are added to `package.json`:
|
|
21
23
|
|
|
@@ -40,5 +42,4 @@ The TanStack Start Vite dev server also auto-emits Prisma Next contract artifact
|
|
|
40
42
|
|
|
41
43
|
Node-based Prisma Next projects expect Node.js 24 LTS or newer.
|
|
42
44
|
|
|
43
|
-
The home route uses a TanStack Start server function to load users through the Prisma Next helper in `src/
|
|
44
|
-
|
|
45
|
+
The home route uses a TanStack Start server function to load users through the Prisma Next helper in `src/prisma/users.ts`.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createFileRoute } from "@tanstack/react-router";
|
|
2
2
|
import { createServerFn } from "@tanstack/react-start";
|
|
3
3
|
|
|
4
|
-
import { listUsers as listStarterUsers } from "../
|
|
4
|
+
import { listUsers as listStarterUsers } from "../prisma/users";
|
|
5
5
|
|
|
6
6
|
const listUsers = createServerFn({ method: "GET" }).handler(async () => {
|
|
7
7
|
return listStarterUsers(10)
|
|
@@ -38,7 +38,7 @@ function Home() {
|
|
|
38
38
|
<h1>Users from your database, loaded through a server function.</h1>
|
|
39
39
|
<p className="lede">
|
|
40
40
|
This route uses TanStack Start's server function API and the Prisma Next helper in{" "}
|
|
41
|
-
<code>src/
|
|
41
|
+
<code>src/prisma/users.ts</code>.
|
|
42
42
|
</p>
|
|
43
43
|
</div>
|
|
44
44
|
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import "dotenv/config";
|
|
2
|
-
{{#if (eq provider "mongo")}}
|
|
3
|
-
import mongo from "@prisma-next/mongo/runtime";
|
|
4
|
-
{{else}}
|
|
5
|
-
import postgres from "@prisma-next/postgres/runtime";
|
|
6
|
-
{{/if}}
|
|
7
|
-
|
|
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
|
-
|
|
14
|
-
import type { Contract } from "../../prisma/contract.d";
|
|
15
|
-
import contractJson from "../../prisma/contract.json" with { type: "json" };
|
|
16
|
-
|
|
17
|
-
{{#if (eq provider "mongo")}}
|
|
18
|
-
export const db = mongo<Contract>({
|
|
19
|
-
contractJson,
|
|
20
|
-
url: process.env["DATABASE_URL"]!,
|
|
21
|
-
});
|
|
22
|
-
{{else}}
|
|
23
|
-
export const db = postgres<Contract>({
|
|
24
|
-
contractJson,
|
|
25
|
-
url: process.env["DATABASE_URL"]!,
|
|
26
|
-
});
|
|
27
|
-
{{/if}}
|
|
28
|
-
|
|
29
|
-
type UserRow = DefaultModelRow<Contract, "User">;
|
|
30
|
-
|
|
31
|
-
{{#if (eq provider "mongo")}}
|
|
32
|
-
function toStarterUser(user: Pick<UserRow, "_id" | "email" | "username" | "name">) {
|
|
33
|
-
return {
|
|
34
|
-
id: String(user._id),
|
|
35
|
-
email: user.email,
|
|
36
|
-
username: user.username ?? null,
|
|
37
|
-
name: user.name ?? null,
|
|
38
|
-
createdAt: null as Date | null,
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
{{else}}
|
|
42
|
-
function toStarterUser(user: Pick<UserRow, "id" | "email" | "username" | "name" | "createdAt">) {
|
|
43
|
-
return {
|
|
44
|
-
id: String(user.id),
|
|
45
|
-
email: user.email,
|
|
46
|
-
username: user.username ?? null,
|
|
47
|
-
name: user.name ?? null,
|
|
48
|
-
createdAt: user.createdAt,
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
{{/if}}
|
|
52
|
-
|
|
53
|
-
export async function listUsers(limit = 10) {
|
|
54
|
-
|
|
55
|
-
{{#if (eq provider "mongo")}}
|
|
56
|
-
const users: ReturnType<typeof toStarterUser>[] = [];
|
|
57
|
-
|
|
58
|
-
for await (const user of db.orm.users.select("_id", "email", "username", "name").take(limit).all()) {
|
|
59
|
-
users.push(toStarterUser(user));
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
return users;
|
|
63
|
-
{{else}}
|
|
64
|
-
const users = await db.orm.User.select("id", "email", "username", "name", "createdAt").take(limit).all();
|
|
65
|
-
|
|
66
|
-
return users.map(toStarterUser);
|
|
67
|
-
{{/if}}
|
|
68
|
-
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
export type StarterUser = Awaited<ReturnType<typeof listUsers>>[number];
|
|
72
|
-
|
|
73
|
-
export default db;
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import "dotenv/config";
|
|
2
|
-
{{#if (eq provider "mongo")}}
|
|
3
|
-
import mongo from "@prisma-next/mongo/runtime";
|
|
4
|
-
{{else}}
|
|
5
|
-
import postgres from "@prisma-next/postgres/runtime";
|
|
6
|
-
{{/if}}
|
|
7
|
-
|
|
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
|
-
|
|
14
|
-
import type { Contract } from "../../prisma/contract.d";
|
|
15
|
-
import contractJson from "../../prisma/contract.json" with { type: "json" };
|
|
16
|
-
|
|
17
|
-
{{#if (eq provider "mongo")}}
|
|
18
|
-
export const db = mongo<Contract>({
|
|
19
|
-
contractJson,
|
|
20
|
-
url: process.env["DATABASE_URL"]!,
|
|
21
|
-
});
|
|
22
|
-
{{else}}
|
|
23
|
-
export const db = postgres<Contract>({
|
|
24
|
-
contractJson,
|
|
25
|
-
url: process.env["DATABASE_URL"]!,
|
|
26
|
-
});
|
|
27
|
-
{{/if}}
|
|
28
|
-
|
|
29
|
-
type UserRow = DefaultModelRow<Contract, "User">;
|
|
30
|
-
|
|
31
|
-
{{#if (eq provider "mongo")}}
|
|
32
|
-
function toStarterUser(user: Pick<UserRow, "_id" | "email" | "username" | "name">) {
|
|
33
|
-
return {
|
|
34
|
-
id: String(user._id),
|
|
35
|
-
email: user.email,
|
|
36
|
-
username: user.username ?? null,
|
|
37
|
-
name: user.name ?? null,
|
|
38
|
-
createdAt: null as Date | null,
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
{{else}}
|
|
42
|
-
function toStarterUser(user: Pick<UserRow, "id" | "email" | "username" | "name" | "createdAt">) {
|
|
43
|
-
return {
|
|
44
|
-
id: String(user.id),
|
|
45
|
-
email: user.email,
|
|
46
|
-
username: user.username ?? null,
|
|
47
|
-
name: user.name ?? null,
|
|
48
|
-
createdAt: user.createdAt,
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
{{/if}}
|
|
52
|
-
|
|
53
|
-
export async function listUsers(limit = 10) {
|
|
54
|
-
|
|
55
|
-
{{#if (eq provider "mongo")}}
|
|
56
|
-
const users: ReturnType<typeof toStarterUser>[] = [];
|
|
57
|
-
|
|
58
|
-
for await (const user of db.orm.users.select("_id", "email", "username", "name").take(limit).all()) {
|
|
59
|
-
users.push(toStarterUser(user));
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
return users;
|
|
63
|
-
{{else}}
|
|
64
|
-
const users = await db.orm.User.select("id", "email", "username", "name", "createdAt").take(limit).all();
|
|
65
|
-
|
|
66
|
-
return users.map(toStarterUser);
|
|
67
|
-
{{/if}}
|
|
68
|
-
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
export type StarterUser = Awaited<ReturnType<typeof listUsers>>[number];
|
|
72
|
-
|
|
73
|
-
export default db;
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import "dotenv/config";
|
|
2
|
-
{{#if (eq provider "mongo")}}
|
|
3
|
-
import mongo from "@prisma-next/mongo/runtime";
|
|
4
|
-
{{else}}
|
|
5
|
-
import postgres from "@prisma-next/postgres/runtime";
|
|
6
|
-
{{/if}}
|
|
7
|
-
|
|
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
|
-
|
|
14
|
-
import type { Contract } from "../../prisma/contract.d";
|
|
15
|
-
import contractJson from "../../prisma/contract.json" with { type: "json" };
|
|
16
|
-
|
|
17
|
-
{{#if (eq provider "mongo")}}
|
|
18
|
-
export const db = mongo<Contract>({
|
|
19
|
-
contractJson,
|
|
20
|
-
url: process.env["DATABASE_URL"]!,
|
|
21
|
-
});
|
|
22
|
-
{{else}}
|
|
23
|
-
export const db = postgres<Contract>({
|
|
24
|
-
contractJson,
|
|
25
|
-
url: process.env["DATABASE_URL"]!,
|
|
26
|
-
});
|
|
27
|
-
{{/if}}
|
|
28
|
-
|
|
29
|
-
type UserRow = DefaultModelRow<Contract, "User">;
|
|
30
|
-
|
|
31
|
-
{{#if (eq provider "mongo")}}
|
|
32
|
-
function toStarterUser(user: Pick<UserRow, "_id" | "email" | "username" | "name">) {
|
|
33
|
-
return {
|
|
34
|
-
id: String(user._id),
|
|
35
|
-
email: user.email,
|
|
36
|
-
username: user.username ?? null,
|
|
37
|
-
name: user.name ?? null,
|
|
38
|
-
createdAt: null as Date | null,
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
{{else}}
|
|
42
|
-
function toStarterUser(user: Pick<UserRow, "id" | "email" | "username" | "name" | "createdAt">) {
|
|
43
|
-
return {
|
|
44
|
-
id: String(user.id),
|
|
45
|
-
email: user.email,
|
|
46
|
-
username: user.username ?? null,
|
|
47
|
-
name: user.name ?? null,
|
|
48
|
-
createdAt: user.createdAt,
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
{{/if}}
|
|
52
|
-
|
|
53
|
-
export async function listUsers(limit = 10) {
|
|
54
|
-
|
|
55
|
-
{{#if (eq provider "mongo")}}
|
|
56
|
-
const users: ReturnType<typeof toStarterUser>[] = [];
|
|
57
|
-
|
|
58
|
-
for await (const user of db.orm.users.select("_id", "email", "username", "name").take(limit).all()) {
|
|
59
|
-
users.push(toStarterUser(user));
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
return users;
|
|
63
|
-
{{else}}
|
|
64
|
-
const users = await db.orm.User.select("id", "email", "username", "name", "createdAt").take(limit).all();
|
|
65
|
-
|
|
66
|
-
return users.map(toStarterUser);
|
|
67
|
-
{{/if}}
|
|
68
|
-
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
export type StarterUser = Awaited<ReturnType<typeof listUsers>>[number];
|
|
72
|
-
|
|
73
|
-
export default db;
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import "dotenv/config";
|
|
2
|
-
{{#if (eq provider "mongo")}}
|
|
3
|
-
import mongo from "@prisma-next/mongo/runtime";
|
|
4
|
-
{{else}}
|
|
5
|
-
import postgres from "@prisma-next/postgres/runtime";
|
|
6
|
-
{{/if}}
|
|
7
|
-
|
|
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
|
-
|
|
14
|
-
import type { Contract } from "../../prisma/contract.d";
|
|
15
|
-
import contractJson from "../../prisma/contract.json" with { type: "json" };
|
|
16
|
-
|
|
17
|
-
{{#if (eq provider "mongo")}}
|
|
18
|
-
export const db = mongo<Contract>({
|
|
19
|
-
contractJson,
|
|
20
|
-
url: process.env["DATABASE_URL"]!,
|
|
21
|
-
});
|
|
22
|
-
{{else}}
|
|
23
|
-
export const db = postgres<Contract>({
|
|
24
|
-
contractJson,
|
|
25
|
-
url: process.env["DATABASE_URL"]!,
|
|
26
|
-
});
|
|
27
|
-
{{/if}}
|
|
28
|
-
|
|
29
|
-
type UserRow = DefaultModelRow<Contract, "User">;
|
|
30
|
-
|
|
31
|
-
{{#if (eq provider "mongo")}}
|
|
32
|
-
function toStarterUser(user: Pick<UserRow, "_id" | "email" | "username" | "name">) {
|
|
33
|
-
return {
|
|
34
|
-
id: String(user._id),
|
|
35
|
-
email: user.email,
|
|
36
|
-
username: user.username ?? null,
|
|
37
|
-
name: user.name ?? null,
|
|
38
|
-
createdAt: null as Date | null,
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
{{else}}
|
|
42
|
-
function toStarterUser(user: Pick<UserRow, "id" | "email" | "username" | "name" | "createdAt">) {
|
|
43
|
-
return {
|
|
44
|
-
id: String(user.id),
|
|
45
|
-
email: user.email,
|
|
46
|
-
username: user.username ?? null,
|
|
47
|
-
name: user.name ?? null,
|
|
48
|
-
createdAt: user.createdAt,
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
{{/if}}
|
|
52
|
-
|
|
53
|
-
export async function listUsers(limit = 10) {
|
|
54
|
-
|
|
55
|
-
{{#if (eq provider "mongo")}}
|
|
56
|
-
const users: ReturnType<typeof toStarterUser>[] = [];
|
|
57
|
-
|
|
58
|
-
for await (const user of db.orm.users.select("_id", "email", "username", "name").take(limit).all()) {
|
|
59
|
-
users.push(toStarterUser(user));
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
return users;
|
|
63
|
-
{{else}}
|
|
64
|
-
const users = await db.orm.User.select("id", "email", "username", "name", "createdAt").take(limit).all();
|
|
65
|
-
|
|
66
|
-
return users.map(toStarterUser);
|
|
67
|
-
{{/if}}
|
|
68
|
-
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
export type StarterUser = Awaited<ReturnType<typeof listUsers>>[number];
|
|
72
|
-
|
|
73
|
-
export default db;
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import "dotenv/config";
|
|
2
|
-
{{#if (eq provider "mongo")}}
|
|
3
|
-
import mongo from "@prisma-next/mongo/runtime";
|
|
4
|
-
{{else}}
|
|
5
|
-
import postgres from "@prisma-next/postgres/runtime";
|
|
6
|
-
{{/if}}
|
|
7
|
-
|
|
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
|
-
|
|
14
|
-
import type { Contract } from "../../prisma/contract.d";
|
|
15
|
-
import contractJson from "../../prisma/contract.json" with { type: "json" };
|
|
16
|
-
|
|
17
|
-
{{#if (eq provider "mongo")}}
|
|
18
|
-
export const db = mongo<Contract>({
|
|
19
|
-
contractJson,
|
|
20
|
-
url: process.env["DATABASE_URL"]!,
|
|
21
|
-
});
|
|
22
|
-
{{else}}
|
|
23
|
-
export const db = postgres<Contract>({
|
|
24
|
-
contractJson,
|
|
25
|
-
url: process.env["DATABASE_URL"]!,
|
|
26
|
-
});
|
|
27
|
-
{{/if}}
|
|
28
|
-
|
|
29
|
-
type UserRow = DefaultModelRow<Contract, "User">;
|
|
30
|
-
|
|
31
|
-
{{#if (eq provider "mongo")}}
|
|
32
|
-
function toStarterUser(user: Pick<UserRow, "_id" | "email" | "username" | "name">) {
|
|
33
|
-
return {
|
|
34
|
-
id: String(user._id),
|
|
35
|
-
email: user.email,
|
|
36
|
-
username: user.username ?? null,
|
|
37
|
-
name: user.name ?? null,
|
|
38
|
-
createdAt: null as Date | null,
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
{{else}}
|
|
42
|
-
function toStarterUser(user: Pick<UserRow, "id" | "email" | "username" | "name" | "createdAt">) {
|
|
43
|
-
return {
|
|
44
|
-
id: String(user.id),
|
|
45
|
-
email: user.email,
|
|
46
|
-
username: user.username ?? null,
|
|
47
|
-
name: user.name ?? null,
|
|
48
|
-
createdAt: user.createdAt,
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
{{/if}}
|
|
52
|
-
|
|
53
|
-
export async function listUsers(limit = 10) {
|
|
54
|
-
|
|
55
|
-
{{#if (eq provider "mongo")}}
|
|
56
|
-
const users: ReturnType<typeof toStarterUser>[] = [];
|
|
57
|
-
|
|
58
|
-
for await (const user of db.orm.users.select("_id", "email", "username", "name").take(limit).all()) {
|
|
59
|
-
users.push(toStarterUser(user));
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
return users;
|
|
63
|
-
{{else}}
|
|
64
|
-
const users = await db.orm.User.select("id", "email", "username", "name", "createdAt").take(limit).all();
|
|
65
|
-
|
|
66
|
-
return users.map(toStarterUser);
|
|
67
|
-
{{/if}}
|
|
68
|
-
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
export type StarterUser = Awaited<ReturnType<typeof listUsers>>[number];
|
|
72
|
-
|
|
73
|
-
export default db;
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import "dotenv/config";
|
|
2
|
-
{{#if (eq provider "mongo")}}
|
|
3
|
-
import mongo from "@prisma-next/mongo/runtime";
|
|
4
|
-
{{else}}
|
|
5
|
-
import postgres from "@prisma-next/postgres/runtime";
|
|
6
|
-
{{/if}}
|
|
7
|
-
|
|
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
|
-
|
|
14
|
-
import type { Contract } from "../../prisma/contract.d";
|
|
15
|
-
import contractJson from "../../prisma/contract.json" with { type: "json" };
|
|
16
|
-
|
|
17
|
-
{{#if (eq provider "mongo")}}
|
|
18
|
-
export const db = mongo<Contract>({
|
|
19
|
-
contractJson,
|
|
20
|
-
url: process.env["DATABASE_URL"]!,
|
|
21
|
-
});
|
|
22
|
-
{{else}}
|
|
23
|
-
export const db = postgres<Contract>({
|
|
24
|
-
contractJson,
|
|
25
|
-
url: process.env["DATABASE_URL"]!,
|
|
26
|
-
});
|
|
27
|
-
{{/if}}
|
|
28
|
-
|
|
29
|
-
type UserRow = DefaultModelRow<Contract, "User">;
|
|
30
|
-
|
|
31
|
-
{{#if (eq provider "mongo")}}
|
|
32
|
-
function toStarterUser(user: Pick<UserRow, "_id" | "email" | "username" | "name">) {
|
|
33
|
-
return {
|
|
34
|
-
id: String(user._id),
|
|
35
|
-
email: user.email,
|
|
36
|
-
username: user.username ?? null,
|
|
37
|
-
name: user.name ?? null,
|
|
38
|
-
createdAt: null as Date | null,
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
{{else}}
|
|
42
|
-
function toStarterUser(user: Pick<UserRow, "id" | "email" | "username" | "name" | "createdAt">) {
|
|
43
|
-
return {
|
|
44
|
-
id: String(user.id),
|
|
45
|
-
email: user.email,
|
|
46
|
-
username: user.username ?? null,
|
|
47
|
-
name: user.name ?? null,
|
|
48
|
-
createdAt: user.createdAt,
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
{{/if}}
|
|
52
|
-
|
|
53
|
-
export async function listUsers(limit = 10) {
|
|
54
|
-
|
|
55
|
-
{{#if (eq provider "mongo")}}
|
|
56
|
-
const users: ReturnType<typeof toStarterUser>[] = [];
|
|
57
|
-
|
|
58
|
-
for await (const user of db.orm.users.select("_id", "email", "username", "name").take(limit).all()) {
|
|
59
|
-
users.push(toStarterUser(user));
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
return users;
|
|
63
|
-
{{else}}
|
|
64
|
-
const users = await db.orm.User.select("id", "email", "username", "name", "createdAt").take(limit).all();
|
|
65
|
-
|
|
66
|
-
return users.map(toStarterUser);
|
|
67
|
-
{{/if}}
|
|
68
|
-
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
export type StarterUser = Awaited<ReturnType<typeof listUsers>>[number];
|
|
72
|
-
|
|
73
|
-
export default db;
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import "dotenv/config";
|
|
2
|
-
{{#if (eq provider "mongo")}}
|
|
3
|
-
import mongo from "@prisma-next/mongo/runtime";
|
|
4
|
-
{{else}}
|
|
5
|
-
import postgres from "@prisma-next/postgres/runtime";
|
|
6
|
-
{{/if}}
|
|
7
|
-
|
|
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
|
-
|
|
14
|
-
import type { Contract } from "../../../prisma/contract.d";
|
|
15
|
-
import contractJson from "../../../prisma/contract.json" with { type: "json" };
|
|
16
|
-
|
|
17
|
-
{{#if (eq provider "mongo")}}
|
|
18
|
-
export const db = mongo<Contract>({
|
|
19
|
-
contractJson,
|
|
20
|
-
url: process.env["DATABASE_URL"]!,
|
|
21
|
-
});
|
|
22
|
-
{{else}}
|
|
23
|
-
export const db = postgres<Contract>({
|
|
24
|
-
contractJson,
|
|
25
|
-
url: process.env["DATABASE_URL"]!,
|
|
26
|
-
});
|
|
27
|
-
{{/if}}
|
|
28
|
-
|
|
29
|
-
type UserRow = DefaultModelRow<Contract, "User">;
|
|
30
|
-
|
|
31
|
-
{{#if (eq provider "mongo")}}
|
|
32
|
-
function toStarterUser(user: Pick<UserRow, "_id" | "email" | "username" | "name">) {
|
|
33
|
-
return {
|
|
34
|
-
id: String(user._id),
|
|
35
|
-
email: user.email,
|
|
36
|
-
username: user.username ?? null,
|
|
37
|
-
name: user.name ?? null,
|
|
38
|
-
createdAt: null as Date | null,
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
{{else}}
|
|
42
|
-
function toStarterUser(user: Pick<UserRow, "id" | "email" | "username" | "name" | "createdAt">) {
|
|
43
|
-
return {
|
|
44
|
-
id: String(user.id),
|
|
45
|
-
email: user.email,
|
|
46
|
-
username: user.username ?? null,
|
|
47
|
-
name: user.name ?? null,
|
|
48
|
-
createdAt: user.createdAt,
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
{{/if}}
|
|
52
|
-
|
|
53
|
-
export async function listUsers(limit = 10) {
|
|
54
|
-
|
|
55
|
-
{{#if (eq provider "mongo")}}
|
|
56
|
-
const users: ReturnType<typeof toStarterUser>[] = [];
|
|
57
|
-
|
|
58
|
-
for await (const user of db.orm.users.select("_id", "email", "username", "name").take(limit).all()) {
|
|
59
|
-
users.push(toStarterUser(user));
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
return users;
|
|
63
|
-
{{else}}
|
|
64
|
-
const users = await db.orm.User.select("id", "email", "username", "name", "createdAt").take(limit).all();
|
|
65
|
-
|
|
66
|
-
return users.map(toStarterUser);
|
|
67
|
-
{{/if}}
|
|
68
|
-
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
export type StarterUser = Awaited<ReturnType<typeof listUsers>>[number];
|
|
72
|
-
|
|
73
|
-
export default db;
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import "dotenv/config";
|
|
2
|
-
{{#if (eq provider "mongo")}}
|
|
3
|
-
import mongo from "@prisma-next/mongo/runtime";
|
|
4
|
-
{{else}}
|
|
5
|
-
import postgres from "@prisma-next/postgres/runtime";
|
|
6
|
-
{{/if}}
|
|
7
|
-
|
|
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
|
-
|
|
14
|
-
import type { Contract } from "../../prisma/contract.d";
|
|
15
|
-
import contractJson from "../../prisma/contract.json" with { type: "json" };
|
|
16
|
-
|
|
17
|
-
{{#if (eq provider "mongo")}}
|
|
18
|
-
export const db = mongo<Contract>({
|
|
19
|
-
contractJson,
|
|
20
|
-
url: process.env["DATABASE_URL"]!,
|
|
21
|
-
});
|
|
22
|
-
{{else}}
|
|
23
|
-
export const db = postgres<Contract>({
|
|
24
|
-
contractJson,
|
|
25
|
-
url: process.env["DATABASE_URL"]!,
|
|
26
|
-
});
|
|
27
|
-
{{/if}}
|
|
28
|
-
|
|
29
|
-
type UserRow = DefaultModelRow<Contract, "User">;
|
|
30
|
-
|
|
31
|
-
{{#if (eq provider "mongo")}}
|
|
32
|
-
function toStarterUser(user: Pick<UserRow, "_id" | "email" | "username" | "name">) {
|
|
33
|
-
return {
|
|
34
|
-
id: String(user._id),
|
|
35
|
-
email: user.email,
|
|
36
|
-
username: user.username ?? null,
|
|
37
|
-
name: user.name ?? null,
|
|
38
|
-
createdAt: null as Date | null,
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
{{else}}
|
|
42
|
-
function toStarterUser(user: Pick<UserRow, "id" | "email" | "username" | "name" | "createdAt">) {
|
|
43
|
-
return {
|
|
44
|
-
id: String(user.id),
|
|
45
|
-
email: user.email,
|
|
46
|
-
username: user.username ?? null,
|
|
47
|
-
name: user.name ?? null,
|
|
48
|
-
createdAt: user.createdAt,
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
{{/if}}
|
|
52
|
-
|
|
53
|
-
export async function listUsers(limit = 10) {
|
|
54
|
-
|
|
55
|
-
{{#if (eq provider "mongo")}}
|
|
56
|
-
const users: ReturnType<typeof toStarterUser>[] = [];
|
|
57
|
-
|
|
58
|
-
for await (const user of db.orm.users.select("_id", "email", "username", "name").take(limit).all()) {
|
|
59
|
-
users.push(toStarterUser(user));
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
return users;
|
|
63
|
-
{{else}}
|
|
64
|
-
const users = await db.orm.User.select("id", "email", "username", "name", "createdAt").take(limit).all();
|
|
65
|
-
|
|
66
|
-
return users.map(toStarterUser);
|
|
67
|
-
{{/if}}
|
|
68
|
-
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
export type StarterUser = Awaited<ReturnType<typeof listUsers>>[number];
|
|
72
|
-
|
|
73
|
-
export default db;
|