dbgate/packages/sqltree/README.md

40 lines
695 B
Markdown
Raw Normal View History

2020-11-16 20:35:18 +00:00
# @dbgate/sqltree
JavaScript/TypeScript SQL query-builder library
@dbgate/sqltree hold query definition in RAW JSON objects.
## Sample usage
```javascript
const { treeToSql, dumpSqlSelect } = require('@dbgate/sqltree');
const engines = require('@dbgate/engines');
const select = {
commandType: 'select',
from: { name: 'Album' },
columns: [
{
exprType: 'column',
columnName: 'name',
}
]
})),
orderBy: [
{
exprType: 'column',
columnName: 'id',
direction: 'ASC',
},
],
};
const sql = treeToSql(engines('mysql'), select, dumpSqlSelect);
console.log('Generated SQL', sqll);
```
## Installation
yarn add @dbgate/sqltree