mirror of
https://github.com/dbgate/dbgate
synced 2024-11-07 20:26:23 +00:00
npm packages
This commit is contained in:
parent
b51a343323
commit
a3a4923397
@ -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
|
||||
|
@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "dbgate-api",
|
||||
"main": "src/index.js",
|
||||
"version": "1.0.1",
|
||||
"version": "1.0.2",
|
||||
|
||||
"homepage": "https://dbgate.org/",
|
||||
"repository": {
|
||||
|
@ -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
|
||||
|
@ -1,5 +1,5 @@
|
||||
{
|
||||
"version": "1.0.1",
|
||||
"version": "1.0.2",
|
||||
"name": "dbgate-sqltree",
|
||||
"main": "lib/index.js",
|
||||
"typings": "lib/index.d.ts",
|
||||
|
Loading…
Reference in New Issue
Block a user