Database CRUD APIs Auto-Generation
Last updated
Last updated
© Copyright 2023, Astera Software
Users can auto-generate CRUD API endpoints for any database using the Data Source Browser. CRUD APIs are meant for Create-Retrieve-Update-Delete operations on the database table records.
Click on View in the main menu bar and select Data Source Browser from the drop-down menu.
This will open the Data Source Browser.
Add a new database server by selecting the Add Database Server option.
This will open a configuration window to define a database connection. A database server can be configured from any of the listed providers.
Add all the essential details to configure the database server connection and click OK.
Now, the Data Source Browser will be populated with all the databases from the connected server.
Right-click on any database and select Generate CRUD flows from the context menu.
Note: It is necessary for a project to be open when CRUD API flows are generated, since they are added under a CRUD folder created in the project.
This will open a new window.
Here, you can select the tables and the respective CRUD operations to generate API flows.
For our use case, we will be selecting the Orders table. The following operations are available for each table:
Find all records – A Get method that fetches all the records
Get record by ID – A Get method along with a path parameter for a key that fetches the records based on the key.
Create a new record – Selecting this creates a new record.
Update a record by ID – Selecting this option lets the user update a record by ID
Delete a record by ID – Selecting this option lets the user delete a record by ID.
The user can even select configurations inside each endpoint, whether they want to enable sort or filter, or whether their execution type is Synchronous or Asynchronous.
Once done, click Generate and the CRUD flows will be generated.
You can then view the API endpoints in the Project Explorer.
Now, you can directly group and deploy with a single click,
or open any of the API flows to see pre-configured API flows or make any changes.
This concludes the working of the Database APIs CRUD auto-generation in Astera.