@@ -5,10 +5,13 @@ The filter API allows you to filter the results of a query by property values an
55## Filtering by property values
66
77``` tsx
8- export class Event extends Entity .Class <Event >(" Event" )({
9- name: Type .String ,
10- cancelled: Type .Boolean ,
11- }) {}
8+ export const Event = Entity .Schema (
9+ { name: Type .String , cancelled: Type .Boolean },
10+ {
11+ types: [Id (' event-type-id' )],
12+ properties: { name: Id (' name-property-id' ), cancelled: Id (' cancelled-property-id' ) },
13+ },
14+ );
1215
1316// inside the React component
1417const { data } = useEntities (Event , {
@@ -128,11 +131,17 @@ const { data } = useEntities(Person, {
128131
129132``` tsx
130133// schema
131- export class Todo extends Entity .Class <Todo2 >(' Todo' )({
132- name: Type .String ,
133- checked: Type .Boolean ,
134- assignees: Type .Relation (User ),
135- })
134+ export const Todo = Entity .Schema (
135+ { name: Type .String , checked: Type .Boolean , assignees: Type .Relation (User ) },
136+ {
137+ types: [Id (' todo-type-id' )],
138+ properties: {
139+ name: Id (' name-property-id' ),
140+ checked: Id (' checked-property-id' ),
141+ assignees: Id (' assignees-property-id' ),
142+ },
143+ },
144+ );
136145```
137146
1381471 level filtering
@@ -171,15 +180,17 @@ const { data } = useEntities(Person, {
171180
172181``` tsx
173182// schema
174- export class Todo extends Entity .Class <Todo2 >(' Todo' )({
175- name: Type .String ,
176- checked: Type .Boolean ,
177- assignees: Type .Relation (User , {
178- entity: {
179- assignedAt: Type .DateTime ,
180- }
181- }),
182- })
183+ export const Todo = Entity .Schema (
184+ { name: Type .String , checked: Type .Boolean , assignees: Type .Relation (User ) },
185+ {
186+ types: [Id (' todo-type-id' )],
187+ properties: {
188+ name: Id (' name-property-id' ),
189+ checked: Id (' checked-property-id' ),
190+ assignees: Id (' assignees-property-id' ),
191+ },
192+ },
193+ );
183194```
184195
185196``` tsx
0 commit comments