RestBI Documentation
  • Welcome to RestBI
  • Getting Started
    • Quickstart Guide for RestBI
    • Installation
      • Docker Compose
      • Kubernetes
  • Object Definitions
    • Data Model
      • Model
      • Connection
      • Table
      • Join
      • Column
      • Formula
      • ValidationResult
    • Query
      • Query
      • QueryFilter
      • SQLResult
  • SDK
    • Overview
    • Reference
      • RestBIClient
      • executeQuery
      • getMetadata
      • validateModel
  • API
    • Overview
    • Reference
      • POST /query
      • POST /validate
      • POST /metadata
      • GET /
  • Examples
    • RestBI Demo App
      • Installation
      • Report Builder
      • Drill Anywhere
      • Model Helper
Powered by GitBook
On this page
  1. SDK
  2. Reference

executeQuery

Understanding the executeQuery Method

executeQuery(query: Query, model: Model): Promise<SQLResult>

Description: Generates and executes an SQL query based on the provided model and query object.

  • Parameters:

    • query (Query): A Query object representing the SQL query to execute.

    • model (Model): A Model object representing the data model.

  • Returns:

    • A Promise that resolves to an SQLResult object or rejects with an SQLError.

Example:

client.executeQuery({
  columns: ["Album Title"],
  filters: [
    {
      column: "ArtistId",
      operator: "=",
      value: 1
    }
  ],
  limit: 10
}, {
  id: "1",
  name: "ChinookModel",
  connection: {
    id: "2",
    name: "Chinook",
    host: "localhost",
    port: 5432,
    user: "postgres",
    password: "test",
    database: "chinook",
    type: DatabaseType.POSTGRES
  },
  tables: [
    {
      id: "1",
      dbName: "album",
      name: "Album",
      columns: [
        {
          id: "title",
          dbName: "title",
          name: "Album Title",
          dataType: ColumnDataType.STRING
        }
      ]
    }
  ],
  joins: [],
  formulas: [],
  filters: []
}).then((result) => {
  console.log(result);
}).catch((error) => {
  console.error(error);
});
PreviousRestBIClientNextgetMetadata

Last updated 9 months ago