Data Management

How to combine two objects into a single array

Summary

Hey there! In this guide, we'll explore how to return a list of mixed objects from different tables using Xano's no-code platform. This can be incredibly useful when you need to combine data from multiple sources into a single response.

Step 1: Create Your Data Models

First things first, you'll need to set up your data models in Xano. For this example, let's assume we have two tables: `Info` and `User`.

Step 2: Get Records from Different Tables

To retrieve data from multiple tables, we'll use the `get record` operation. Here's how you can do it:

  1. Drag and drop the `get record` operation onto the canvas.
  2. In the configuration panel, select the `Info` table from the "Table" dropdown.
  3. Repeat step 1, but this time select the `User` table.

You should now have two separate `get record` operations, one for each table.

Step 3: Combine the Results

Now that we have the data from both tables, it's time to combine them into a single array. Follow these steps:

  1. Create a new variable called `combinedResult` and set its type to `array`.
  2. Drag and drop the `push` operation onto the canvas.
  3. In the `push` operation's configuration panel, select the `combinedResult` variable from the "Array" dropdown.
  4. For the "Value" field, connect the output of the first `get record` operation (e.g., `info1`).
  5. Repeat steps 2-4, but this time connect the output of the second `get record` operation (e.g., `user1`) to the "Value" field.

Your canvas should now have a `combinedResult` array containing objects from both the `Info` and `User` tables.

Step 4: Return the Combined Result

Finally, we need to return the `combinedResult` array as the operation's output:

  1. Drag and drop the `return` operation onto the canvas.
  2. In the configuration panel, connect the `combinedResult` variable to the "Value" field.

And that's it! When you run this operation, Xano will return a list containing objects from both the `Info` and `User` tables, seamlessly combined into a single response.

By following these steps, you can easily create mixed lists of objects from different tables, enabling you to build more powerful and flexible applications with Xano's no-code platform.

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