Skip to content

Commit bd67784

Browse files
committed
update to v2
1 parent 9b5bb7d commit bd67784

File tree

8 files changed

+408
-3608
lines changed

8 files changed

+408
-3608
lines changed

package-lock.json

Lines changed: 275 additions & 3316 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@
1414
"dependencies": {
1515
"@clerk/nextjs": "^5.0.2",
1616
"@prisma/client": "5.12.0",
17-
"@zenstackhq/runtime": "^1.12.4",
18-
"@zenstackhq/server": "^1.12.4",
19-
"@zenstackhq/swr": "^1.12.4",
17+
"@zenstackhq/runtime": "2.0.0",
18+
"@zenstackhq/server": "2.0.0",
19+
"@zenstackhq/swr": "2.0.0",
2020
"next": "^14.2.3",
2121
"react": "18.2.0",
2222
"react-dom": "18.2.0",
@@ -38,7 +38,7 @@
3838
"prisma": "5.12.0",
3939
"tailwindcss": "^3.2.0",
4040
"typescript": "^4.8.4",
41-
"zenstack": "^1.12.4"
41+
"zenstack": "2.0.0"
4242
},
4343
"ct3aMetadata": {
4444
"initVersion": "6.11.3"

prisma/schema.prisma

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,27 @@
44
//////////////////////////////////////////////////////////////////////////////////////////////
55

66
datasource db {
7-
provider = "sqlite"
8-
url = env("DATABASE_URL")
7+
provider = "sqlite"
8+
url = env("DATABASE_URL")
99
}
1010

1111
generator client {
12-
provider = "prisma-client-js"
12+
provider = "prisma-client-js"
1313
}
1414

1515
/// @@allow('all', auth() != null && auth().id == authorId)
1616
/// @@allow('read', auth() != null && published)
1717
model Post {
18-
id String @id() @default(cuid())
19-
createdAt DateTime @default(now())
20-
updatedAt DateTime @updatedAt()
21-
title String
22-
published Boolean @default(false)
23-
authorId String
18+
id String @id() @default(cuid())
19+
createdAt DateTime @default(now())
20+
updatedAt DateTime @updatedAt()
21+
title String
22+
published Boolean @default(false)
23+
authorId String
2424
}
2525

2626
model User {
27-
id String @id()
27+
id String @id()
2828
29-
@@ignore()
30-
}
29+
@@ignore()
30+
}

src/components/PostItem.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
import type { Post } from "@prisma/client";
22
import { useEffect, useState } from "react";
3-
import { useMutatePost } from "../lib/hooks";
3+
import { useDeletePost, useUpdatePost } from "../lib/hooks";
44

55
type Props = { post: Post };
66

77
export const PostItem = ({ post }: Props) => {
8-
const { updatePost, deletePost } = useMutatePost();
8+
const { trigger: updatePost } = useUpdatePost();
9+
const { trigger: deletePost } = useDeletePost();
910
const [email, setEmail] = useState<string>("");
1011

1112
useEffect(() => {

src/lib/hooks/__model_meta.ts

Lines changed: 41 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,46 @@
11
/* eslint-disable */
22
const metadata = {
3-
fields: {
3+
models: {
44
post: {
5-
id: {
6-
name: 'id',
7-
type: 'String',
8-
isId: true,
9-
attributes: [{ name: '@default', args: [] }],
10-
},
11-
createdAt: {
12-
name: 'createdAt',
13-
type: 'DateTime',
14-
attributes: [{ name: '@default', args: [] }],
15-
},
16-
updatedAt: {
17-
name: 'updatedAt',
18-
type: 'DateTime',
19-
attributes: [{ name: '@updatedAt', args: [] }],
20-
},
21-
title: {
22-
name: 'title',
23-
type: 'String',
24-
},
25-
published: {
26-
name: 'published',
27-
type: 'Boolean',
28-
attributes: [{ name: '@default', args: [{ value: false }] }],
29-
},
30-
authorId: {
31-
name: 'authorId',
32-
type: 'String',
33-
},
34-
},
35-
},
36-
uniqueConstraints: {
37-
post: {
38-
id: {
39-
name: 'id',
40-
fields: ['id'],
41-
},
42-
},
43-
},
44-
deleteCascade: {},
5+
name: 'Post', fields: {
6+
id: {
7+
name: "id",
8+
type: "String",
9+
isId: true,
10+
attributes: [{ "name": "@default", "args": [] }],
11+
}, createdAt: {
12+
name: "createdAt",
13+
type: "DateTime",
14+
attributes: [{ "name": "@default", "args": [] }],
15+
}, updatedAt: {
16+
name: "updatedAt",
17+
type: "DateTime",
18+
attributes: [{ "name": "@updatedAt", "args": [] }],
19+
}, title: {
20+
name: "title",
21+
type: "String",
22+
}, published: {
23+
name: "published",
24+
type: "Boolean",
25+
attributes: [{ "name": "@default", "args": [{ "value": false }] }],
26+
}, authorId: {
27+
name: "authorId",
28+
type: "String",
29+
},
30+
}
31+
, uniqueConstraints: {
32+
id: {
33+
name: "id",
34+
fields: ["id"]
35+
},
36+
}
37+
,
38+
}
39+
,
40+
}
41+
,
42+
deleteCascade: {
43+
}
44+
,
4545
};
4646
export default metadata;

0 commit comments

Comments
 (0)