dbservice returns the result of the query (res.rows). When I get the result I want to create the lazy repeat list but I get this error:

delegate" parameter must be an object.

If I put the delegate initialization code outside the select function then the list renders ok (but without the data i need to show).
Is there a proper way to create the list when I have the data? Is it a good idea to call the select function inside the configureItemScope field of the delegate object? That would mean that it would make too many calls to the database while scrolling… right?

When you specify the delegate it must be an object and it should contain at least the countItems and configureItemScope methods.

You seem to have already found your solution, in my opinion that is probably the best one out there.

Alternatives may include things like loading the page with the lazy repeat only after you receive the data or calling it from configureItemScope but in a smart way.

In general if you’re using lazy repeat it makes sense only when the number of items is around 1000+, in which case maybe you could get them from the server in chunks rather than all of them from the beginning.

Also if you’ve already gotten something from the server you should remember it rather than making another request for it.

But you can see that these things look a little ugly and need changes to the server/dbService, so maybe you try out things like these only at a later point and only if you think that it’s necessary.
It all depends on the amount of data which you’re working with.

Anyway for now I think what you have should be enough. Just don’t forget to unindent properly