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
  • Deploy RestBI with Docker
  • Install the SDK
  • Define Your Data Model
  • Create a Query
  • Get the Dataset
  • Whats Next - Demo App
  1. Getting Started

Quickstart Guide for RestBI

Install, Configure the Models, and execute Queries

Deploy RestBI with Docker

To get started quickly with RestBI, you can deploy the RestBI server using Docker. The Docker image is available on DockerHub, making deployment simple and fast.

Pull the Docker image from DockerHub:

docker pull restbi/restbi-server:latest

Run the RestBI server with the following command:

docker run -d -p 3000:3000 restbi/restbi-server:latest

Install the SDK

Next, we need to install the SDK from npm. Open your terminal and run the following command in your project directory:

npm install restbi-sdk

Define Your Data Model

Create a data model file. This file will define the connection, tables, columns, joins, and formulas specific to your database. This keeps connection details secure and allows the RestBI server to generate accurate SQL queries based on your model.

Example: dataModel.ts

const connection: Connection = {
    id: '1',
    name: 'AdventureWorks',
    host: 'host.docker.internal',
    port: 5432,
    user: 'postgres',
    password: 'postgres',
    database: 'AdventureWorks',
    type: DatabaseType.POSTGRES,
};
const AdventureWorksModel: Model = {
    id: 'adventureworks',
    name: 'Adventure Works',
    connection: connection,
    tables: [ /* Define your tables here */ ],
    joins: [ /* Define your joins here */ ],
    formulas: [ /* Define your formulas here */ ],
};

Model files are typically stored on the back-end of your application. Use environmental variables to set sensitive information.

Create a Query

Create a query to fetch data from your database. The query will specify the columns you want to retrieve, any filters, sorting options, and a limit on the number of rows.

Example: query.ts

import { Query } from 'bi-sdk';

export const sampleQuery: Query = {
    columns: ['Total Due', 'Order Date'],
    filters: [
        {
            column: 'Order Date',
            operator: '>=',
            value: new Date('2024-01-01'),
        },
    ],
    limit: 100,
};

This query selects the Total Due and Order Date columns from the database, applies a filter to only include records where the Order Date is on or after January 1, 2024, and limits the results to 100 rows. It's equivalent to a SQL SELECT statement with a WHERE clause and a LIMIT.

Get the Dataset

Use the SDK to send the query to the server. The SDK will handle communication with the server and return the results.

Example: index.ts

import { BIClient } from 'bi-sdk';
import { AdventureWorksModel } from './dataModel';
import { sampleQuery } from './query';

const client = new BIClient('http://localhost:3000');

client.executeQuery(sampleQuery, AdventureWorksModel)
    .then(result => {
        console.log('Query result:', result);
    })
    .catch(error => {
        console.error('Error executing query:', error);
    });

PreviousWelcome to RestBINextInstallation

Last updated 8 months ago

and : Learn how to define tables and columns for your model.

: Understand how to link your tables with joins.

: Create complex calculations and logic using formulas.

This will return a object containing the dataset.

Whats Next -

The is a great way for you to see the art of the possible in RestBI.

- See how easy it is to add filtering, drilling and more to common charting libraries like AgGrid and ChartJS.

- A dynamic interface for self service. See how to combine the Model and Query in a flexible interface.

- Explore how models are built, the validate function, and even plugin GPT to generate models for you.

Tables
Columns
Joins
Formulas
SQL Result
Demo App
Demo App
Drill Anywhere
Report Builder
Model Helper