@@ -134,12 +134,17 @@ user = User.find(params);
134134user. addCustomAttribute(CustomAttribute . newStringAttribute(" role" , " captain" ));
135135User . update(user);
136136
137- // Iterate over all users
137+ // Iterate over all users (up to 10k records, to read all use Scroll API)
138138UserCollection users = User . list();
139139while (users. hasNext()) {
140140 System . out. println(users. next(). getUserId());
141141}
142142
143+ // Retrieve users via Scroll API
144+ ScrollableUserCollection usersScroll = User . scroll();
145+ List<User > users = usersScroll. getPage();
146+ usersScroll = usersScroll. scroll();
147+
143148// Bulk submit users
144149final List<JobItem<User > > items = Lists . newArrayList();
145150items. add(new JobItem<User > (" post" , user1));
@@ -187,12 +192,18 @@ while(contacts.hasNext()) {
187192 System . out. println(contacts. next());
188193}
189194
190- // Iterate over all contacts
195+ // Iterate over all contacts (up to 10k records, to read all use Scroll API)
191196ContactCollection allContacts = Contact . list();
192197while (allContacts. hasNext()) {
193198 System . out. println(allContacts. next());
194199}
195200
201+ // Retrieve contacts via Scroll API
202+ ScrollableContactCollection contactsScroll = Contact . scroll();
203+ List<Contact > contacts = contactsScroll. getPage();
204+ contactsScroll = contactsScroll. scroll();
205+
206+
196207// Remove a contact
197208Contact . delete(contact);
198209
@@ -586,6 +597,8 @@ These return a Collection object (eg `UserCollection`) which can be iterated in
586597
587598- Java's inbuilt iterator methods ` next() ` and ` hasNext() ` - these are useful when you want to fetch data without manually handling pagination.
588599
600+ - User and Contact listing only works up to 10k records. To retrieve all records use the Scroll API via ` scroll() `
601+
589602### Error handling
590603
591604You do not need to deal with the HTTP response from an API call directly.
0 commit comments