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

ParamTypeDescription
inputreaderTypereader object
outputwriterTypewriter object
optionsobjectoptions

deployDb(options)

Deploys database model stored in modelFolder (table as yamls) to database

Kind: global function

ParamTypeDescription
optionsobject
options.connectionconnectionTypeconnection object
options.systemConnectionobjectsystem connection (result of driver.connect). If not provided, new connection will be created
options.driverobjectdriver object. If not provided, it will be loaded from connection
options.analysedStructureobjectanalysed structure of the database. If not provided, it will be loaded
options.modelFolderstringfolder with model files (YAML files for tables, SQL files for views, procedures, …)
options.loadedDbModelArray.<object>loaded database model - collection of yaml and SQL files loaded into array
options.modelTransformsArray.<function()>array of functions for transforming model
options.dbdiffOptionsExtraobjectextra options for dbdiff
options.ignoreNameRegexstringregex for ignoring objects by name
options.targetSchemastringtarget schema for deployment
options.maxMissingTablesRationumbermaximum 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

ParamTypeDescription
optionsobject
options.connectionconnectionTypeconnection object
options.systemConnectionobjectsystem connection (result of driver.connect). If not provided, new connection will be created
options.driverobjectdriver object. If not provided, it will be loaded from connection
options.analysedStructureobjectanalysed structure of the database. If not provided, it will be loaded

executeQuery(options)

Executes SQL query

Kind: global function

ParamTypeDescription
optionsobject
[options.connection]connectionTypeconnection object
[options.systemConnection]objectsystem connection (result of driver.connect). If not provided, new connection will be created
[options.driver]objectdriver object. If not provided, it will be loaded from connection
[options.sql]stringSQL query
[options.sqlFile]stringSQL file
[options.logScriptItems]booleanwhether to log script items instead of whole script

generateDeploySql(options)

Generates query for deploying model into database

Kind: global function

ParamTypeDescription
optionsobject
options.connectionconnectionTypeconnection object
options.systemConnectionobjectsystem connection (result of driver.connect). If not provided, new connection will be created
options.driverobjectdriver object. If not provided, it will be loaded from connection
options.analysedStructureobjectanalysed structure of the database. If not provided, it will be loaded
options.modelFolderstringfolder with model files (YAML files for tables, SQL files for views, procedures, …)
options.loadedDbModelArray.<object>loaded database model - collection of yaml and SQL files loaded into array
options.modelTransformsArray.<function()>array of functions for transforming model
options.dbdiffOptionsExtraobjectextra options for dbdiff
options.ignoreNameRegexstringregex for ignoring objects by name
options.targetSchemastringtarget schema for deployment
options.maxMissingTablesRationumbermaximum 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

ParamTypeDescription
optionsObject
options.fileNamestringfile name or URL
options.encodingstringencoding of the file
options.limitRowsnumbermaximum 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

ParamTypeDescription
optionsobject
options.fileNamestringfile name
[options.encoding]stringencoding of the file
[options.header]booleanwhether 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

ParamTypeDescription
optionsobject
options.fileNamestringfile name or URL
options.jsonStylestring‘object’ or ‘array’
[options.keyField]stringkey field for object style
[options.rootField]stringroot field for object style
[options.encoding]stringencoding of the file
[options.limitRows]numbermaximum 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

ParamTypeDescription
optionsobject
options.fileNamestringfile name
[options.jsonStyle]string‘object’ or ‘array’
[options.keyField]stringkey field for object style
[options.rootField]stringroot field for object style
[options.encoding]stringencoding 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

ParamTypeDescription
optionsobject
options.connectionconnectionTypeconnection object
options.querystringSQL query
[options.queryType]stringquery type
[options.sql]stringSQL 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

ParamTypeDescription
optionsobject
options.connectionconnectionTypeconnection object
options.systemConnectionobjectsystem connection (result of driver.connect). If not provided, new connection will be created
options.pureNamestringtable name
options.schemaNamestringschema 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

ParamTypeDescription
optionsobject
options.connectionconnectionTypeconnection object
options.systemConnectionobjectsystem connection (result of driver.connect). If not provided, new connection will be created
options.driverobjectdriver object. If not provided, it will be loaded from connection
options.pureNamestringtable name
options.schemaNamestringschema name
options.dropIfExistsbooleandrop table if exists
options.truncatebooleantruncate table before insert
options.createIfNotExistsbooleancreate table if not exists
options.commitAfterInsertbooleancommit transaction after insert

readerType : Object

Reader (input) object for copyStream function

Kind: global typedef

writerType : Object

Writer (output) object for copyStream function

Kind: global typedef

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.

Kind: global typedef

connectionType : Object

Kind: global typedef
Properties

NameType
engineengineType
serverstring
userstring
passwordstring
databasestring
portstring