dbgate/packages/sqltree
2021-04-01 12:49:57 +02:00
..
src prettier 2021-01-23 07:24:46 +01:00
.gitignore introduced sqltree typescript library 2020-03-05 07:35:23 +01:00
.yarnrc sqltree readme 2020-11-30 20:13:31 +01:00
package.json set dependency version to 4.0.0 2021-04-01 12:49:57 +02:00
README.md fixed repo links 2021-02-11 10:11:34 +01:00
tsconfig.json packages, documentation 2020-03-13 22:42:09 +01:00

dbgate-sqltree

JavaScript/TypeScript SQL query-builder library

dbgate-sqltree hold query definition in RAW JSON objects.

Sample usage

const { treeToSql, dumpSqlSelect } = require("dbgate-sqltree");
const dbgatePluginMysql = require("dbgate-plugin-mysql");

const select = {
  commandType: "select",
  from: {
    name: {
      pureName: "Album",
    },
  },
  columns: [
    {
      exprType: "column",
      columnName: "name",
    },
  ],
  orderBy: [
    {
      exprType: "column",
      columnName: "id",
      direction: "ASC",
    },
  ],
};

const sql = treeToSql(dbgatePluginMysql.driver, select, dumpSqlSelect);
console.log("Generated query:", sql);

See TypeScript definitions for complete list of available SQL command options.

Installation

yarn add dbgate-sqltree