dbgate-sqltree is a JavaScript/TypeScript SQL query-builder library that represents SQL queries as raw JSON objects. The current stable version is 7.1.13. It supports multiple SQL dialects including MySQL, PostgreSQL, MSSQL, and SQLite through driver plugins. Unlike ORM-based solutions, it provides a low-level, flexible JSON structure for constructing queries programmatically. The library is part of the dbgate ecosystem and relies on external database plugins for SQL dialect specifics. It is primarily used for generating SQL strings from query trees.
npm install dbgate-sqltreeNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows how to create a SELECT query tree and convert it to SQL using MySQL dialect.
Update query trees to include exprType for columns and use { pureName: 'tableName' } for table names.Ensure your query tree matches the expected TypeScript interfaces (see types.ts in repo).
Switch to ESM imports with named exports.
Use ESM imports or destructure from the require result.
Run npm install dbgate-plugin-mysql
Use import { treeToSql } from 'dbgate-sqltree'Ensure query object follows the TypeScript interfaces; check for typos.