Skip to main content

CRUD Operations with Xest

Crud Operations


File Structure

The pattern of Xest file structure is routes > controllers > actions > queries.

In the src folder, you will see app and actions folders. In the app folder, you will have controller functions, which can be assumed as the brain of the software.

Router: The routing mechanism controls which controller receives which requests.

Controller: The brains of the application that controls how data is displayed. Controllers are responsible for validating incoming request formats and returning valid responses to the client.

Action: This is where all the actions takes place which talk to the database. You will write most of your queries underneath this directory. Actions can be used by a number of different controllers, or anywhere in your application as necessary.

Query: This is a SQL query file which uses submitQuery and other relevant database helpers to talk to the database. Query files can be used directly from anywhere in your application or they can be wrapped in action modules.

Naming Conventions

Xest recommends naming your controller/action/query files depending on the type of CRUD operation you are performing.

Creating somethingpostcreateinsert
Reading some datagetfetchselect
Updating some dataputmodifyupdate
Deleting some datadeleteremovedelete


In order to create something within the API e.g user, you need to use post for controller, create for actions, and insert for the query function.


In order to read something within the API e.g user, you need to use get for controller, fetch for actions, and select for the query function.


In order to update something within the API e.g user, you need to use put for controller, modify for actions, and update for the query function.


In order to delete something within the API e.g user, you need to use delete for controller, remove for actions, and delete for the query function.