1.0.12 • Published 1 year ago

vega-transform-db v1.0.12

Weekly downloads
-
License
BSD-3-Clause
Repository
github
Last release
1 year ago

vega-transform-db

Data transform to load data from a database in Vega.

This package extends Vega's set of data transforms to support loading data from a database in Vega version 5.0 and higher.

Usage Instructions

Install the transform with

yarn add vega-transform-db

To use the transform, you must initially set the type. We currently aim to support 2 types of interaction with a database either via a middleware server or directly through a query function. So if you intend to use a server set the type to Server or Serverless if you're passing a query function, then register the transform as dbtransform.

import VegaTransformDB from "vega-transform-db"

VegaTransformDB.type('Serverless'); 
transforms["dbtransform"] = VegaTransformDB;

Further examples for using the package with a middleware server and with a serverless query function.

API Reference

# VegaTransformDB.type(type: string = "Serverless")

  • This function is used to indicate whether the transform will be interacting with a middleware server VegaTransformDB.type('Server') or not VegaTransformDB.type('Serverless')

# VegaTransformDB.QueryFunction(function)

  • If the type has been set to Serverless, this function is used to indicate which query function is to be used when a sql query is encountered.

# VegaTransformDB.setHttpOptions(object)

  • If the type has been set to Server, this function is used to set the Http POST request options, i.e,
const httpOptions = {
    'url': 'http://localhost:3000/query',
    'mode': 'cors',
    'method': 'POST',
    'headers': {
      'Content-Type': 'application/x-www-form-urlencoded'
    }
  };
VegaTransformDB.type('Server');
vega.transforms["dbtransform"] = VegaTransformDB;
VegaTransformDB.setHttpOptions(httpOptions);

This example indicates that when a query is to be executed it will send a POST request at http://localhost:3000/query with sql query.

1.0.11

1 year ago

1.0.12

1 year ago

1.0.10

2 years ago

1.0.9

2 years ago

1.0.8

2 years ago

1.0.7

2 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago