From a3a49233979cb4d9cf5265be5af21982c0b120c3 Mon Sep 17 00:00:00 2001 From: Jan Prochazka Date: Tue, 17 Nov 2020 08:27:14 +0100 Subject: [PATCH] npm packages --- packages/api/README.md | 15 +++++++++++++++ packages/api/package.json | 2 +- packages/sqltree/README.md | 35 ++++++++++++++++++++--------------- packages/sqltree/package.json | 2 +- 4 files changed, 37 insertions(+), 17 deletions(-) diff --git a/packages/api/README.md b/packages/api/README.md index ab17dd5b..89b1a47d 100644 --- a/packages/api/README.md +++ b/packages/api/README.md @@ -28,6 +28,21 @@ dbgateApi.runScript(run); ``` +Silly example, runs without any dependencies. Copy [fakeObjectReader](https://github.com/dbshell/dbgate/blob/master/packages/api/src/shell/fakeObjectReader.js) to [consoleObjectWriter](https://github.com/dbshell/dbgate/blob/master/packages/api/src/shell/consoleObjectWriter.js) . + +```javascript + +const dbgateApi = require('dbgate-api'); +async function run() { + const reader = await dbgateApi.fakeObjectReader(); + const writer = await dbgateApi.consoleObjectWriter(); + await dbgateApi.copyStream(reader, writer); + console.log('Finished job script'); +} +dbgateApi.runScript(run); + +``` + ## dbgateApi functions ### dbgateApi.copyStream diff --git a/packages/api/package.json b/packages/api/package.json index beb7b48f..c9e4b02a 100644 --- a/packages/api/package.json +++ b/packages/api/package.json @@ -1,7 +1,7 @@ { "name": "dbgate-api", "main": "src/index.js", - "version": "1.0.1", + "version": "1.0.2", "homepage": "https://dbgate.org/", "repository": { diff --git a/packages/sqltree/README.md b/packages/sqltree/README.md index 7911f7c8..4eabbb4c 100644 --- a/packages/sqltree/README.md +++ b/packages/sqltree/README.md @@ -7,33 +7,38 @@ dbgate-sqltree hold query definition in RAW JSON objects. ## Sample usage ```javascript -const { treeToSql, dumpSqlSelect } = require('dbgate-sqltree'); -const engines = require('dbgate-engines'); +const { treeToSql, dumpSqlSelect } = require("dbgate-sqltree"); +const engines = require("dbgate-engines"); const select = { - commandType: 'select', - from: { name: 'Album' }, + commandType: "select", + from: { + name: { + pureName: "Album", + }, + }, columns: [ - { - exprType: 'column', - columnName: 'name', - } - ] - })), + { + exprType: "column", + columnName: "name", + }, + ], orderBy: [ { - exprType: 'column', - columnName: 'id', - direction: 'ASC', + exprType: "column", + columnName: "id", + direction: "ASC", }, ], }; -const sql = treeToSql(engines('mysql'), select, dumpSqlSelect); -console.log('Generated SQL', sqll); +const sql = treeToSql(engines("mysql"), select, dumpSqlSelect); +console.log("Generated query:", sql); ``` +See [TypeScript definitions](https://github.com/dbshell/dbgate/blob/master/packages/sqltree/src/types.ts) for complete list of available SQL command options. + ## Installation yarn add dbgate-sqltree diff --git a/packages/sqltree/package.json b/packages/sqltree/package.json index 28c0ae4e..707072bd 100644 --- a/packages/sqltree/package.json +++ b/packages/sqltree/package.json @@ -1,5 +1,5 @@ { - "version": "1.0.1", + "version": "1.0.2", "name": "dbgate-sqltree", "main": "lib/index.js", "typings": "lib/index.d.ts",