@@ -72,7 +72,7 @@ import { schema } from '@data-client/rest';
72
72
import { useQuery , useFetch } from ' @data-client/react' ;
73
73
import { UserResource , User } from ' ./resources/User' ;
74
74
75
- const getUserCount = new schema .Query (
75
+ const countUsers = new schema .Query (
76
76
new schema .All (User ),
77
77
(entries , { isAdmin } = {}) => {
78
78
if (isAdmin !== undefined )
@@ -83,8 +83,8 @@ const getUserCount = new schema.Query(
83
83
84
84
function UsersPage() {
85
85
useFetch (UserResource .getList );
86
- const userCount = useQuery (getUserCount );
87
- const adminCount = useQuery (getUserCount , { isAdmin: true });
86
+ const userCount = useQuery (countUsers );
87
+ const adminCount = useQuery (countUsers , { isAdmin: true });
88
88
if (userCount === undefined ) return <div >No users in cache yet</div >;
89
89
return (
90
90
<div >
@@ -181,18 +181,13 @@ interface Props {
181
181
``` tsx title="TodoJoined"
182
182
import { schema } from ' @data-client/rest' ;
183
183
import { useQuery , useFetch } from ' @data-client/react' ;
184
- import { TodoResource , Todo } from ' ./resources/Todo' ;
184
+ import { TodoResource } from ' ./resources/Todo' ;
185
185
import { UserResource } from ' ./resources/User' ;
186
186
import TodoByUser from ' ./TodoByUser' ;
187
187
188
188
const groupTodoByUser = new schema .Query (
189
189
TodoResource .getList .schema ,
190
- todos => {
191
- return Object .groupBy (todos , todo => todo .userId ) as Record <
192
- number ,
193
- Todo []
194
- >;
195
- },
190
+ todos => Object .groupBy (todos , todo => todo .userId ),
196
191
);
197
192
198
193
function TodosPage() {
@@ -213,7 +208,6 @@ function TodosPage() {
213
208
</div >
214
209
);
215
210
}
216
-
217
211
render (<TodosPage />);
218
212
```
219
213
0 commit comments