dbgate/packages/sqltree
2020-11-17 08:27:14 +01:00
..
src renamed dbgate packages, because of npmjs policy 2020-11-16 21:59:08 +01:00
.gitignore introduced sqltree typescript library 2020-03-05 07:35:23 +01:00
package.json npm packages 2020-11-17 08:27:14 +01:00
README.md npm packages 2020-11-17 08:27:14 +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 engines = require("dbgate-engines");

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

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

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

Installation

yarn add dbgate-sqltree