Data Management

Add Record

Summary

Hey there! Let's learn how to easily add records to your Xano database tables using the handy "Add Record" function. Follow along as we guide you through the process step-by-step.

Step 1: Access the "Add Record" Function

First things first, locate the "Add Record" function. Head over to the "Function Stack" and navigate to the "Database Requests" section. You'll find the "Add Record" function listed there.

Step 2: Select the Target Table

Next, choose the table you want to add records to. Click on the "Add Record" function, and a dropdown will appear, allowing you to select any of your existing tables in Xano.

For this example, let's say we want to add records to the "Product" table. Simply select it from the dropdown.

Step 3: Map Input Fields

Once you've selected the target table, Xano will automatically populate the input fields based on the table's schema. Your job is to map these input fields to the appropriate values.

In many cases, these values will be dynamic, coming from user inputs, variables, or other sources within your function stack. For demonstration purposes, we'll use a "Database Link" input to fetch the schema from the "Product" table.

To add a "Database Link" input:

  1. Click the "+" icon to add a new input.
  2. Select "Database Link" from the input type dropdown.
  3. Choose the "Product" table from the dropdown that appears.

Now, you can map each input field to its corresponding value by clicking on the field and selecting the appropriate input from the dropdown.

For example:

  • Map the "name" field to the "name" input.
  • Map the "description" field to the "description" input.
  • Map the "user ID" field to the "user ID" input.

Step 4: Run the Function

With all the input fields mapped, you're ready to add a new record to your database! Click the "Run" button, and if you've provided valid inputs, a new record will be added to the "Product" table.

Additional Tips

Hiding Input Fields

If you don't want to show all input fields in your function, you can easily hide them. Click the toggle button at the top of the input fields section to hide or unhide them all at once.

Mapping Multiple Fields to a Single Input

In cases where you want to map multiple fields to a single input (e.g., an object or array), use the "magic wand" icon next to the input field. This will map all fields to the selected input.

Customizing Output

After running the "Add Record" function, you can further customize the output or add additional functionality by using the "Output" tab. This allows you to modify the response or perform additional operations on the newly added record.

And that's it! You've successfully learned how to use the "Add Record" function in Xano to easily add records to your database tables. 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