API Documentation
Functions
- copyStream(input, output, options) ⇒
Promise
Copies reader to writer. Used for import, export tables and transfer data between tables
- deployDb(options)
Deploys database model stored in modelFolder (table as yamls) to database
- dropAllDbObjects(options) ⇒
Promise
Drops all database objects
- executeQuery(options)
Executes SQL query
- generateDeploySql(options)
Generates query for deploying model into database
- jsonLinesReader(options) ⇒
Promise.<readerType>
Reader function, which reads JSNOL file or URL. JSONL format - text file, every line is JSON encoded row.
- jsonLinesWriter(options) ⇒
Promise.<writerType>
Returns writer object for copyStream function. This writer object writes data to JSONL file. JSONL format - text file, every line is JSON encoded row, used eg. by MongoDB.
- jsonReader(options) ⇒
Promise.<readerType>
Creates reader object for JSON file for copyStream function.
- jsonWriter(options) ⇒
Promise.<writerType>
Returns writer object for copyStream function. This writer object writes data to JSON file.
- queryReader(options) ⇒
Promise.<readerType>
Returns reader object for copyStream function. This reader object reads data from query.
- tableReader(options) ⇒
Promise.<readerType>
Creates reader object for copyStream function. This reader object reads data from table or view.
- tableWriter(options) ⇒
Promise.<writerType>
Creates writer object for copyStream function. This writer object writes data to table. Table could be created if not exists.
Typedefs
- readerType :
Object
Reader (input) object for copyStream function
- writerType :
Object
Writer (output) object for copyStream function
- engineType :
'mysql@dbgate-plugin-mysql'
|'mariadb@dbgate-plugin-mysql'
|'postgres@dbgate-plugin-postgres'
|'sqlite@dbgate-plugin-sqlite'
|'oracle@dbgate-plugin-oracle'
|'cockroach@dbgate-plugin-postgres'
|'redshift@dbgate-plugin-postgres'
Typ uživatelské role.
- connectionType :
Object
copyStream(input, output, options) ⇒ Promise
Copies reader to writer. Used for import, export tables and transfer data between tables
Kind: global function
Param | Type | Description |
---|---|---|
input | readerType |
reader object |
output | writerType |
writer object |
options | object |
options |
deployDb(options)
Deploys database model stored in modelFolder (table as yamls) to database
Kind: global function
Param | Type | Description |
---|---|---|
options | object |
|
options.connection | connectionType |
connection object |
options.systemConnection | object |
system connection (result of driver.connect). If not provided, new connection will be created |
options.driver | object |
driver object. If not provided, it will be loaded from connection |
options.analysedStructure | object |
analysed structure of the database. If not provided, it will be loaded |
options.modelFolder | string |
folder with model files (YAML files for tables, SQL files for views, procedures, …) |
options.loadedDbModel | Array.<object> |
loaded database model - collection of yaml and SQL files loaded into array |
options.modelTransforms | Array.<function()> |
array of functions for transforming model |
options.dbdiffOptionsExtra | object |
extra options for dbdiff |
options.ignoreNameRegex | string |
regex for ignoring objects by name |
options.targetSchema | string |
target schema for deployment |
options.maxMissingTablesRatio | number |
maximum ratio of missing tables in database. Safety check, if missing ratio is highe, deploy is stopped (preventing accidental drop of all tables) |
dropAllDbObjects(options) ⇒ Promise
Drops all database objects
Kind: global function
Param | Type | Description |
---|---|---|
options | object |
|
options.connection | connectionType |
connection object |
options.systemConnection | object |
system connection (result of driver.connect). If not provided, new connection will be created |
options.driver | object |
driver object. If not provided, it will be loaded from connection |
options.analysedStructure | object |
analysed structure of the database. If not provided, it will be loaded |
executeQuery(options)
Executes SQL query
Kind: global function
Param | Type | Description |
---|---|---|
options | object |
|
[options.connection] | connectionType |
connection object |
[options.systemConnection] | object |
system connection (result of driver.connect). If not provided, new connection will be created |
[options.driver] | object |
driver object. If not provided, it will be loaded from connection |
[options.sql] | string |
SQL query |
[options.sqlFile] | string |
SQL file |
[options.logScriptItems] | boolean |
whether to log script items instead of whole script |
generateDeploySql(options)
Generates query for deploying model into database
Kind: global function
Param | Type | Description |
---|---|---|
options | object |
|
options.connection | connectionType |
connection object |
options.systemConnection | object |
system connection (result of driver.connect). If not provided, new connection will be created |
options.driver | object |
driver object. If not provided, it will be loaded from connection |
options.analysedStructure | object |
analysed structure of the database. If not provided, it will be loaded |
options.modelFolder | string |
folder with model files (YAML files for tables, SQL files for views, procedures, …) |
options.loadedDbModel | Array.<object> |
loaded database model - collection of yaml and SQL files loaded into array |
options.modelTransforms | Array.<function()> |
array of functions for transforming model |
options.dbdiffOptionsExtra | object |
extra options for dbdiff |
options.ignoreNameRegex | string |
regex for ignoring objects by name |
options.targetSchema | string |
target schema for deployment |
options.maxMissingTablesRatio | number |
maximum ratio of missing tables in database. Safety check, if missing ratio is highe, deploy is stopped (preventing accidental drop of all tables) |
jsonLinesReader(options) ⇒ Promise.<readerType>
Reader function, which reads JSNOL file or URL. JSONL format - text file, every line is JSON encoded row.
Kind: global function
Returns: Promise.<readerType>
- - reader object
Param | Type | Description |
---|---|---|
options | Object |
|
options.fileName | string |
file name or URL |
options.encoding | string |
encoding of the file |
options.limitRows | number |
maximum number of rows to read |
jsonLinesWriter(options) ⇒ Promise.<writerType>
Returns writer object for copyStream function. This writer object writes data to JSONL file. JSONL format - text file, every line is JSON encoded row, used eg. by MongoDB.
Kind: global function
Returns: Promise.<writerType>
- - writer object
Param | Type | Description |
---|---|---|
options | object |
|
options.fileName | string |
file name |
[options.encoding] | string |
encoding of the file |
[options.header] | boolean |
whether to write header. Header is JSON describing source table structure. Header is specific to DbGate, if you want eg. to import data to MongoDB, you should not write header. |
jsonReader(options) ⇒ Promise.<readerType>
Creates reader object for JSON file for copyStream function.
Kind: global function
Returns: Promise.<readerType>
- - reader object
Param | Type | Description |
---|---|---|
options | object |
|
options.fileName | string |
file name or URL |
options.jsonStyle | string |
‘object’ or ‘array’ |
[options.keyField] | string |
key field for object style |
[options.rootField] | string |
root field for object style |
[options.encoding] | string |
encoding of the file |
[options.limitRows] | number |
maximum number of rows to read |
jsonWriter(options) ⇒ Promise.<writerType>
Returns writer object for copyStream function. This writer object writes data to JSON file.
Kind: global function
Returns: Promise.<writerType>
- - writer object
Param | Type | Description |
---|---|---|
options | object |
|
options.fileName | string |
file name |
[options.jsonStyle] | string |
‘object’ or ‘array’ |
[options.keyField] | string |
key field for object style |
[options.rootField] | string |
root field for object style |
[options.encoding] | string |
encoding of the file |
queryReader(options) ⇒ Promise.<readerType>
Returns reader object for copyStream function. This reader object reads data from query.
Kind: global function
Returns: Promise.<readerType>
- - reader object
Param | Type | Description |
---|---|---|
options | object |
|
options.connection | connectionType |
connection object |
options.query | string |
SQL query |
[options.queryType] | string |
query type |
[options.sql] | string |
SQL query. obsolete; use query instead |
tableReader(options) ⇒ Promise.<readerType>
Creates reader object for copyStream function. This reader object reads data from table or view.
Kind: global function
Returns: Promise.<readerType>
- - reader object
Param | Type | Description |
---|---|---|
options | object |
|
options.connection | connectionType |
connection object |
options.systemConnection | object |
system connection (result of driver.connect). If not provided, new connection will be created |
options.pureName | string |
table name |
options.schemaName | string |
schema name |
tableWriter(options) ⇒ Promise.<writerType>
Creates writer object for copyStream function. This writer object writes data to table. Table could be created if not exists.
Kind: global function
Returns: Promise.<writerType>
- - writer object
Param | Type | Description |
---|---|---|
options | object |
|
options.connection | connectionType |
connection object |
options.systemConnection | object |
system connection (result of driver.connect). If not provided, new connection will be created |
options.driver | object |
driver object. If not provided, it will be loaded from connection |
options.pureName | string |
table name |
options.schemaName | string |
schema name |
options.dropIfExists | boolean |
drop table if exists |
options.truncate | boolean |
truncate table before insert |
options.createIfNotExists | boolean |
create table if not exists |
options.commitAfterInsert | boolean |
commit transaction after insert |
readerType : Object
Reader (input) object for copyStream function
writerType : Object
Writer (output) object for copyStream function
engineType : 'mysql@dbgate-plugin-mysql'
| 'mariadb@dbgate-plugin-mysql'
| 'postgres@dbgate-plugin-postgres'
| 'sqlite@dbgate-plugin-sqlite'
| 'oracle@dbgate-plugin-oracle'
| 'cockroach@dbgate-plugin-postgres'
| 'redshift@dbgate-plugin-postgres'
Typ uživatelské role.
connectionType : Object
Kind: global typedef
Properties
Name | Type |
---|---|
engine | engineType |
server | string |
user | string |
password | string |
database | string |
port | string |