SQLResult

Understanding SQL Results in RestBI

The SQLResult type is the structure that contains the data returned from executing a SQL query. This is the result that your application will use to display or further process the data retrieved from the database.

Structure of SQLResult

  • columns: string[]

    • An array of column names representing the columns in the result set. Each entry corresponds to a column in the returned rows.

  • rows: Record<string, any>[]

    • An array of row objects, where each object represents a row in the result set. The keys in each object are the column names, and the values are the corresponding data for that row.

Example of an SQLResult

Here’s an example of an SQLResult:

const result: SQLResult = {
    columns: ['OrderID', 'CustomerName', 'TotalDue'],
    rows: [
        { OrderID: 10248, CustomerName: 'Paul Jones', TotalDue: 250.75 },
        { OrderID: 10249, CustomerName: 'Mary Smith', TotalDue: 1000.00 },
        { OrderID: 10250, CustomerName: 'John Doe', TotalDue: 500.50 }
    ]
};

In this example:

  • The columns array lists the names of the columns returned by the query: CustomerID, OrderDate, and TotalDue.

  • The rows array contains individual records where each record is an object with keys corresponding to the column names.

How It's Used

When you use the SDK to execute a query against the backend service, the SQLResult is returned. You can then use this result in your application to display the data in a user-friendly format, such as in tables, charts, or other visual components.

The SQLResult format ensures that your data is organized and easy to work with, allowing you to focus on building great user experiences without worrying about the underlying data structure.

See Also

  • Tables - Understand how data is organized into Tables, the foundation of your database.

  • Columns - Learn about the individual fields within Tables that store your data.

  • Queries - Explore how to retrieve data from your database using structured Queries.

  • Query Filters - Discover how to refine your data retrieval by applying conditions to your Queries.

Last updated