How can you modify and delete existing records in a database?

Changing and deleting records in the database is done by using BPs similar to BPs for adding, so we recommend reading this article.

Let's take the Course data model with fields:

  • Title - string
  • Description - text
  • Price - integer

Let's create a table Course and add buttons Delete and Edit to Action.

Table for example

Deleting records

To delete records, you need to send a request to the server using the Server Request DELETE /{model_name}/:id.

This block needs the ID of the record to be removed.

The element for which the business process is configured is in the table in the Action section; the ID is stored in the triggers of this element, called Record ID.

Let's create BP for the Delete button onClick trigger.

Add the block Server Request DELETE /course/:id and pass the Record ID field from the onClick trigger to it.

BP for deleting record

After clicking the Delete button, the record will be deleted from the table and the database. To see the changes in the table, update the data in it.

Changing records

Two blocks, Server Request PUT /{model_name}/:id and Server Request PATCH /{model_name}/:id, can be used to change records.

The difference between them is that PUT completely updates the entire record (if some fields in the record are not set to update, PUT will reset them), while PATCH updates only the specified fields.

To make them work, you need a data model to update them. To do that, use the make {model_name} block. In this block, pass the ID of the record you want to change.

Let's create a business process for changing a record with the PATCH example.

We need to allow the user to enter new values to change a record.

For that, create a modal window Edit Course and place the necessary input fields in it:

  • InputString for Title;
  • InputText for Description;
  • InputInteger for Price.

Now create a global variable that will store the record ID for editing.

After clicking on the Edit button in the table, we need to save the ID record and open the modal window.

Use the Set Variable block to save and open a modal window using the Modal Show block.

Current record in the modal window

Now you can get the current record in the modal window. Let's display the record values directly in the Edit Course input fields. To do this, configure BP for the modal window.

In it, you'll get the needed record by ID from the global variable and update the input fields with Update Properties blocks.

BP for update the input fields

Next, configure the BP for the Save button in the Edit Course modal window. As in the case of adding an entry, get the values from the input fields using the Get Properties blocks and pass them to the Make course block. Also, pass the ID stored in a variable into this block. After that, pass the course model to the Server Request block PATCH /course/:id. Next, simply close the modal window with the Modal Hide block

BP for the Save button in modal

Now clicking on the Edit button will open a modal window with the ability to edit the record.

After changing a record, the data in the table must also be updated to see the changes.

Was this article helpful? 101 Crash Course

10 modules
2 weeks

Not sure where to start? Get going with our crash course for beginners and explore AppMaster from A to Z.

Start Course
Development it’s so easy with AppMaster!

Need More Help?

Solve any issue with the help of our experts. Save time and focus on building your applications.


Contact Support

Tell us about your problem, and we’ll find you a solution.


Community Chat

Discuss questions with other users in our chat.

Join Community