dbgate/packages/sqltree
2021-02-08 19:22:13 +01: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 version in reposirory should be last stable version 2021-02-08 19:22:13 +01:00
README.md sqltree readme 2020-11-30 20:13:31 +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