Channel Pagination

Last Edit: Mar 03 2020

As shown in the code sample below, pagination for messages uses limit and id_lte parameters for pagination.

The term id_lte stands for ID less than or equal. The ID-based pagination improves performance and prevents issues related to the list of messages changing while you’re paginating.


const result = await channel.query({
    messages: { limit: 2, id_lte: 123 } ,
    members: { limit: 2, offset: 0 } ,
    watchers: { limit: 2, offset: 0 },
});
                    

final response = await channel.query(
  messagesPagination: PaginationParams(limit: 2, lessThanOrEqual: "123"),
  membersPagination:  PaginationParams(limit: 2, offset: 0),
  watchersPagination: PaginationParams(limit: 2, offset: 0),
);
                    

$messages = $channel->query([
		'messages' => ['limit'=>2, 'id_lte' => '123'], 
		'members'  => ['limit'=>2, 'offset' => 0],
		'watchers' => ['limit'=>2, 'offset' => 0]
]);
                    

val filter = Filters.lessThanEquals("cid", cid)
val offset = 0
val limit = 10

val request = QueryChannelsRequest(filter, offset, limit)

client.queryChannels(request).enqueue { 
    val channels = it.data()
}
                    

For members and watchers, we use limit and offset parameters.