# Database CRUD APIs Auto-Generation

### Video

{% embed url="<https://www.youtube.com/watch?v=TsFOK-7hXBg>" %}

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.

1. Click on *View* in the main menu bar and select *Data Source Browser* from the drop-down menu.

![](https://3083465318-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsR50Wa7EwZGlmPSAMkkf%2Fuploads%2Fbt9EuQr1MISErWDMD73i%2F01-Data-Source-Browser-Menu.JPG?alt=media\&token=39c4ecd2-4dfe-4fa7-8820-191484edd943)

This will open the Data Source Browser.

![](https://3083465318-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsR50Wa7EwZGlmPSAMkkf%2Fuploads%2FAWl6Ve8anrC58UnlDBX1%2F02-Data-Source-Browser-Open.JPG?alt=media\&token=fe58385c-e0ba-41c6-be8d-485130537595)

2. Add a new database server by selecting the *Add Database Server* option.

![](https://3083465318-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsR50Wa7EwZGlmPSAMkkf%2Fuploads%2FwSghv0yEMCCEWie3MnRN%2F03-Data-Browser-Add.png?alt=media\&token=2881164d-d94d-4a1c-8931-0d0314a1fc9a)

This will open a configuration window to define a database connection. A database server can be configured from any of the listed providers.

![](https://3083465318-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsR50Wa7EwZGlmPSAMkkf%2Fuploads%2FIjXuHXuhqqee1v1CZZoX%2F02-01-Data-Source-List.JPG?alt=media\&token=27efacf4-76db-4c23-87c1-92a5209e5176)

3. Add all the essential details to configure the database server connection and click *OK*.

![](https://3083465318-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsR50Wa7EwZGlmPSAMkkf%2Fuploads%2FA6uBpWGxjsz4LhVgtpXW%2F04-Data-table-Configure.PNG?alt=media\&token=68c42000-a5e5-4422-924c-90a71aad5eab)

Now, the Data Source Browser will be populated with all the databases from the connected server.

![](https://3083465318-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsR50Wa7EwZGlmPSAMkkf%2Fuploads%2FUT5XWaPX8SWGWmLnEcAe%2F05-Tables-Browser.PNG?alt=media\&token=21890a66-2f70-4e32-8a88-dfa1337c0c08)

4. Right-click on any database and select *Generate CRUD flows* from the context menu.

{% hint style="info" %}
**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.
{% endhint %}

![](https://3083465318-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsR50Wa7EwZGlmPSAMkkf%2Fuploads%2FfLdA9lW0KJtien9axGbX%2F06-CRUD-Flows-Option.PNG?alt=media\&token=091dfaf2-301a-45c4-a2f6-4ed442cbc345)

This will open a new window.

Here, you can select the tables and the respective CRUD operations to generate API flows.

![](https://3083465318-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsR50Wa7EwZGlmPSAMkkf%2Fuploads%2FKYlQ9HgYME5PNCTMOFDz%2F07-CRUD-Window.PNG?alt=media\&token=b76ccf6b-8454-4380-a223-9dc35a75fcf4)

For our use case, we will be selecting the *Orders* table. The following operations are available for each table:

1. *Find all records* – A Get method that fetches all the records
2. *Get record by ID* – A Get method along with a path parameter for a key that fetches the records based on the key.
3. *Create a new record* – Selecting this creates a new record.
4. *Update a record by ID* – Selecting this option lets the user update a record by ID
5. *Delete a record by ID* – Selecting this option lets the user delete a record by ID.

![](https://3083465318-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsR50Wa7EwZGlmPSAMkkf%2Fuploads%2Fy3Rqoa1s9GL0VybT5Ue1%2F08-CRUD-Table-Selection.PNG?alt=media\&token=72ae58ee-bd37-4116-8c76-de1b9135a008)

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.

5. Once done, click *Generate* and the CRUD flows will be generated.

![](https://3083465318-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsR50Wa7EwZGlmPSAMkkf%2Fuploads%2FOCyV9U9VcebE8ErZhLML%2F12-CRUD-Trace.PNG?alt=media\&token=a5164d84-2e9a-4de1-b9a2-ac7e088466c5)

You can then view the API endpoints in the Project Explorer.

![](https://3083465318-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsR50Wa7EwZGlmPSAMkkf%2Fuploads%2FmbX5Ccy56hZfxsWpPtmZ%2F09-CRUD-Tables-Generated.PNG?alt=media\&token=d8b93a26-7b54-403c-b705-9e3032184729)

6. Now, you can directly group and deploy with a single click,

![](https://3083465318-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsR50Wa7EwZGlmPSAMkkf%2Fuploads%2FHGKfkiBZzXaPgFCkHlWq%2F11-Group-Deploy.PNG?alt=media\&token=0d94f60f-a336-4096-9bfd-45f78e9ba410)

or open any of the API flows to see pre-configured API flows or make any changes.

![](https://3083465318-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsR50Wa7EwZGlmPSAMkkf%2Fuploads%2FPTiMH6xqx2u0IBV6Y9sc%2F10-API-Flows.PNG?alt=media\&token=f4ba0d7d-559d-4237-a80d-c58def273710)

This concludes the working of the Database APIs CRUD auto-generation in Astera.

<br>
