Data Management

Edit Record

Summary

Hey there! In this guide, I'll walk you through the process of editing records in your Xano database table using the Edit Record function. This handy feature allows you to update existing data in your table with new values, giving you the flexibility to manage your data effortlessly.

Step 1: Navigate to the Edit Record Function

First things first, let's find the Edit Record function within Xano. Head over to your Function Stack and locate the "Database Requests" section. You'll find the "Edit Record" function there, conveniently labeled as "Edit a record and merge with existing data."

Step 2: Select Your Table

Once you've located the Edit Record function, you'll need to choose the specific table you want to edit. In the function's settings, you'll see a dropdown menu where you can select the desired table from your Xano database.

For this example, let's say we're working with a "Product" table.

Step 3: Find the Record by Field Name

To edit a record, you'll need to identify it by one of the fields in your table. By default, the "Field Name" is set to "ID," but you can change this by clicking the dropdown menu and selecting any other field name from your table.

Let's stick with "ID" for now. Keep in mind that if you choose a field name other than "ID," that field will be removed from the list of editable fields below.

Step 4: Map Your Inputs

Next, you'll need to map your inputs. Start by adding a database link to your "Product" table, which will bring in all the fields and schema information. Then, add a table reference to the same "Product" table.

In the "Field Value" section of the Edit Record function, map the input to the "Product ID" you just added.

Step 5: Unhide and Map Fields to Edit

Now it's time to decide which fields you want to edit. By default, all fields are hidden, but you can unhide them by clicking the eye icon next to each field.

For instance, if you want to edit the "Name," "Description," and "Price" fields, simply unhide them and map the desired values.

If there are fields you don't want to edit, leave them hidden, and Xano will retain their existing values.

Step 6: Save and Run

Once you've mapped all the necessary inputs and fields, save your changes and run the function. Provide the desired values for the fields you want to update.

For example, let's say you want to update the record with ID 1 with a new name ("Cool Product"), description ("ABC"), and price (99). Simply input these values, and Xano will update the corresponding record with the new data.

Conditional Set Filters (Optional)

Xano performs full object replacements, which means that if you don't provide a value for a field, it will be replaced with a blank value. However, you can use Conditional Set Filters to add flexible logic and ensure that existing values are retained if no new value is provided.

For instance, you can add a filter called "First Not Empty" to check if a value is present. If not, Xano will pull the existing value from the record.

To learn more about Conditional Set Filters and how to use them effectively, check out Xano's dedicated tutorial on this topic.

Output and Add-ons

Finally, remember that you can customize the output of the Edit Record function by adjusting the settings in the "Output" tab. Additionally, you can explore various add-ons to enhance the functionality of this feature.

That's it, folks! With Xano's Edit Record function, updating your database records has never been easier. Give it a try and let us know if you have any questions or need further assistance.

This transcript was AI generated to allow users to quickly answer technical questions about Xano.

Was this helpful?

I found it helpful

I need more support
Sign up for XanoSign up for Xano

Build without limits on a secure, scalable backend.

Unblock your team's progress and create a backend that will scale for free.

Start building for free