Load Mails using pagination concept

Hey,

I was looking to load cocuhbase mails using pagination concept. Yeah we have a method to pass the limit (mails count).Below is the method,

(CBLQuery*) select: (NSArray<CBLQuerySelectResult*>)select
from: (CBLQueryDataSource
)from
where: (nullable CBLQueryExpression*)where
groupBy: (nullable NSArray<CBLQueryExpression*>)groupBy
having: (nullable CBLQueryExpression
)having
orderBy: (nullable NSArray<CBLQueryOrdering*>)orderings
limit: (nullable CBLQueryLimit
)limit{

/** Logic goes here */

}

Here i have a doubt, if i give the limit 10/20, can be able to load those number of mails.I don’t need this requirement.

As soon as i scroll the table the view, i would like to pass the Offset value, so that i can be able to get the mails from there itself.

Here in the above code, i am not able to apply the pagination concept.

I would like to load 10 mails on each scroll, not bunch of mails at a time.

Any help would be appreciated…

Hi @Mallesh_Codeforce,

I believe this is a question about Couchbase Lite, and not Couchbase Server, so I’m moving it over to that topic, and I’m tagging some of the engineers who might be able to help.

I don’t understand the question. Yes, you can use an offset and a limit. Did you try it?

Yeah @jens , I tried it .Now i am able to load it using Offset and limit.But i cannot be able to orderBy sorting (Ascending/Descending).

I was using below query for orderBy, but i am not able to get it.Any help would be appreciated.

    _listQuery = [CBLQueryBuilder select:@[S_ID,S_NAME,S_OBJ] from:[CBLQueryDataSource database:_database] where:[TYPE equalTo:[CBLQueryExpression string:@"task_list"]] groupBy:group having:queryExpression orderBy:@[[CBLQueryOrdering expression:NAME],[CBLQueryOrdering property:@"DESC"]] limit:[CBLQueryLimit limit:[CBLQueryExpression integer:10] offset:[CBLQueryExpression integer:Data_limit_str]]];

If you want help you will need to post a complete picture of what you are doing. You have several variables in there that are unknown to us. Try to format your post with the following items:

  1. A complete runnable example (including any documents that need to be inserted)
  2. The expected results
  3. The actual results

Without that all we can do is go back and forth with more and more head scratching.