Pagination and search
All REST routes have pagination if the correct GET parameters are added to the URL on all GET list routes: Site, Idea, Article, Newslettersignup, Argument, Submission & Vote. The heavy lifting is done by express middleware.
If a query param
pageis used the results will be returned in pages. Optionally a param
pageSizecan be used; this defaults to 20.
The results will than be extended with some metadata:
... the results
Pagination is done in the database query. A request for 20 records from a table with 100000 should be fast.
Search does not use the query because fuzzy SQL does not/hardly exist. Search will therefore be done on the results: it will fetch all 100000 records and search those in JS.
Pagination can than only be done after the searching of course, so this might be quite expensive.
Search requests are created with the query param
An npm module like ns will create an url like this form a nested js object.
"title": "goed idee"
Currently searches are recognized for
description. The value
textwill search in all three of these.
andOrshould be self explanatory.
It may seem like overkill, but this way it should be really simple to add new ways of searching.