@@ -43,10 +43,11 @@ import { convertValues } from "../utils";
43
43
export const getSyncEntities = async < S extends Schema > (
44
44
client : ToriiClient ,
45
45
components : Component < S , Metadata , undefined > [ ] ,
46
+ clause : Clause | undefined ,
46
47
entityKeyClause : EntityKeysClause [ ] ,
47
48
limit : number = 100
48
49
) => {
49
- await getEntities ( client , components , limit ) ;
50
+ await getEntities ( client , clause , components , limit ) ;
50
51
return await syncEntities ( client , components , entityKeyClause ) ;
51
52
} ;
52
53
@@ -103,21 +104,22 @@ export const getSyncEvents = async <S extends Schema>(
103
104
*/
104
105
export const getEntities = async < S extends Schema > (
105
106
client : ToriiClient ,
107
+ clause : Clause | undefined ,
106
108
components : Component < S , Metadata , undefined > [ ] ,
107
109
limit : number = 100
108
110
) => {
109
- let cursor = 0 ;
111
+ let offset = 0 ;
110
112
let continueFetching = true ;
111
113
112
114
while ( continueFetching ) {
113
- const entities = await client . getAllEntities ( limit , cursor ) ;
115
+ const entities = await client . getEntities ( { limit, offset , clause } ) ;
114
116
115
117
setEntities ( entities , components ) ;
116
118
117
119
if ( Object . keys ( entities ) . length < limit ) {
118
120
continueFetching = false ;
119
121
} else {
120
- cursor += limit ;
122
+ offset += limit ;
121
123
}
122
124
}
123
125
} ;
0 commit comments