dbgate/packages/sqltree
Jan Prochazka 4f429c27c0 fix
2024-09-11 13:05:42 +02:00
..
src fix 2024-09-11 13:05:42 +02:00
.gitignore
.yarnrc
package.json changed license, added LICENSE-OLD to plugin-oracle 2024-06-26 20:41:14 +02:00
README.md
tsconfig.json

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