You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: blog/react-table/index.md
+13-13Lines changed: 13 additions & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -92,7 +92,7 @@ A [Prisma schema file](https://github.com/ymc9/react-query-table-zenstack/blob/m
92
92
93
93
SQL databases are not meant to be consumed from the frontend. You need an API to mediate. You can build such an API in many ways, but here we'll use [ZenStack](https://zenstack.dev) to "unbuild" it. ZenStack is a full-stack toolkit built above Prisma, and one of the cool things it does is to automagically derive a backend API from the schema.
94
94
95
-
Setting ZenStack up is very easy:
95
+
Setting ZenStack up is straightforward:
96
96
97
97
1. Run `npx zenstack init` to prep the project. It copies the `schema.prisma` file into `schema.zmodel` - which is the schema file used by ZenStack. ZModel is a superset of Prisma schema.
98
98
@@ -133,7 +133,7 @@ I know a big **🚨 NO THIS IS NOT SECURE 🚨** is flashing in your mind. Hold
133
133
134
134
Having a free API is cool, but writing `fetch` to call it is cumbersome. How about some free query hooks? Yes, add the `@zenstackhq/tanstack-query` plugin to the ZModel schema, and you'll have a set of fully typed React Query hooks generated for each model:
@@ -291,7 +292,6 @@ Also, update the hooks call to respect the pagination state:
291
292
```tsx
292
293
const {data} = useFindManyOrderDetail({
293
294
...queryInclude,
294
-
orderBy: computeOrderBy(),
295
295
// highlight-start
296
296
skip: pagination.pageIndex*pagination.pageSize,
297
297
take: pagination.pageSize,
@@ -324,21 +324,21 @@ This part well demonstrates the value of "headless" UI. You don't need to manage
324
324
325
325
We've got a pretty cool table end-to-end working now, with roughly 200 lines of code. Less code is only one of the benefits of this combination. It also provides excellent flexibility in every layer of the stack:
326
326
327
-
- Prisma's query
327
+
- **Prisma's query**
328
328
329
329
Prisma is known for its concise yet powerful query API. It allows you to do complex joins and aggregations without writing SQL. In our example, our table shows data from five tables, and we barely noticed the complexity.
330
330
331
-
- ZenStack's access control
331
+
- **ZenStack's access control**
332
332
333
333
Remember I said we'll get back to the security issue? A real-world API must have an authorization mechanism with it. ZenStack's real power lies in its ability to define access control rules in the data schema. You can define rules like rejecting anonymous users or showing only the orders of the current login employee, etc. Read more details [here](/docs/the-complete-guide/part1/access-policy/).
334
334
335
-
- React Query's fetching
335
+
- **React Query's fetching**
336
336
337
-
React Query provides great flexibility around how data is fetched, cached, and invalidated. Leverage its power to build a highly responsive UI and reduce the load on the database at same time.
337
+
React Query provides great flexibility around how data is fetched, cached, and invalidated. Leverage its power to build a highly responsive UI and reduce the load on the database at same time.
338
338
339
-
- React Table's state management
339
+
- **React Table's state management**
340
340
341
-
React Table has every aspect of a table's state organized for you. It provides a solid pattern to follow without limiting how you render the table UI.
341
+
React Table has every aspect of a table's state organized for you. It provides a solid pattern to follow without limiting how you render the table UI.
0 commit comments