This is a more advanced example, based of a randomly generated list of one million fictious persons.
It takes a file containing multiple JSON documents as an input, and provides an HTTP service with two endpoints.
You can download and run this example locally (using Docker) with the following script.
The source code for this example is also available here.
List everyone in the database
This endpoint allows to list and filter the persons in the database:
GET http://localhost:3003/people
Response body:
Search in the database
The search filter allows advanced searching and filtering a person by either it’s firstName, lastName or userName. This is done by indexing those properties using the FTS5 index.
GET http://localhost:3003/people?search=firstName:John AND lastName:An*
Response body:
Paging
The results are paged using the offset and limit parameters. The default value for limit is 100.
GET http://localhost:3003/people?limit=2&offset=0
Response body:
GET http://localhost:3003/people?limit=2&offset=2
Response body:
Get a specific person by id
This endpoint allows to get a specific record using it’s id property.
The ids are indexed in an SQLite database.