# 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://content.gitbook.com/content/zEifS4h8yurLAAwiGNX2/blobs/diCKIKFWqBQZIEqsOo5t/01-Data-Source-Browser-Menu.JPG)

This will open the Data Source Browser.

![](https://content.gitbook.com/content/zEifS4h8yurLAAwiGNX2/blobs/zHihw8FnpyOQZoxFIOQX/02-Data-Source-Browser-Open.JPG)

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

![](https://content.gitbook.com/content/zEifS4h8yurLAAwiGNX2/blobs/9XxeignB0nOmIAQFUwR6/03-Data-Browser-Add.png)

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

![](https://content.gitbook.com/content/zEifS4h8yurLAAwiGNX2/blobs/reYaGSG6uJt8Y8QjucwR/02-01-Data-Source-List.JPG)

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

![](https://content.gitbook.com/content/zEifS4h8yurLAAwiGNX2/blobs/kUZ8j1U2iYIlEV4ZE1OL/04-Data-table-Configure.PNG)

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

![](https://content.gitbook.com/content/zEifS4h8yurLAAwiGNX2/blobs/ilhekGe07OnAyIKFbcKu/05-Tables-Browser.PNG)

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://content.gitbook.com/content/zEifS4h8yurLAAwiGNX2/blobs/QFo1e1wLWWYYf58gWm1a/06-CRUD-Flows-Option.PNG)

This will open a new window.

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

![](https://content.gitbook.com/content/zEifS4h8yurLAAwiGNX2/blobs/HTFNYxLZTHNKzeFVFFeq/07-CRUD-Window.PNG)

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://content.gitbook.com/content/zEifS4h8yurLAAwiGNX2/blobs/JaDvL1XR7XtPiDmV3udG/08-CRUD-Table-Selection.PNG)

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://content.gitbook.com/content/zEifS4h8yurLAAwiGNX2/blobs/bgIjnEFVUbG1MHbWgys2/12-CRUD-Trace.PNG)

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

![](https://content.gitbook.com/content/zEifS4h8yurLAAwiGNX2/blobs/ycAGWsxWsRGo28miAHOK/09-CRUD-Tables-Generated.PNG)

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

![](https://content.gitbook.com/content/zEifS4h8yurLAAwiGNX2/blobs/9ejNluPiNuRruhvr1Olb/11-Group-Deploy.PNG)

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

![](https://content.gitbook.com/content/zEifS4h8yurLAAwiGNX2/blobs/RpP26IKOekLuL0XbFoiM/10-API-Flows.PNG)

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

<br>
