dbgate/packages/engines
2020-11-17 08:40:08 +01:00
..
default renamed dbgate packages, because of npmjs policy 2020-11-16 21:59:08 +01:00
mssql renamed dbgate packages, because of npmjs policy 2020-11-16 21:59:08 +01:00
mysql renamed dbgate packages, because of npmjs policy 2020-11-16 21:59:08 +01:00
postgres renamed dbgate packages, because of npmjs policy 2020-11-16 21:59:08 +01:00
index.d.ts renamed dbgate packages, because of npmjs policy 2020-11-16 21:59:08 +01:00
index.js ts fix 2020-03-02 21:01:47 +01:00
package.json missing dependency 2020-11-17 08:40:08 +01:00
README.md documentation 2020-11-17 07:37:32 +01:00
tsconfig.json ts fix 2020-03-02 21:01:47 +01:00

dbgate-engines

JavaScript library implementing MySQL, MS SQL and PostgreSQL operations. Server as abstraction layer for other DbGate packages, which could be database-engine independend. It can be used both on frontent (in browser) and on backend (in nodejs), but connection to real database is allowed only on backend.

Installation

yarn add dbgate-engines

Usage

const engines = require('dbgate-engines');
// driver supports operations of EngineDriver listed belowe
const driver = engine('mysql'); 

In most cases, you don't use driver methods directly, but you pass driver instance into other dbgate packages.

Driver definition

export interface EngineDriver {
  // works on both frontend and backend
  engine: string;
  dialect: SqlDialect;
  createDumper(): SqlDumper;

  // works only on backend
  connect(nativeModules, { server, port, user, password, database }): any;
  query(pool: any, sql: string): Promise<QueryResult>;
  stream(pool: any, sql: string, options: StreamOptions);
  readQuery(pool: any, sql: string, structure?: TableInfo): Promise<stream.Readable>;
  writeTable(pool: any, name: NamedObjectInfo, options: WriteTableOptions): Promise<stream.Writeable>;
  analyseSingleObject(
    pool: any,
    name: NamedObjectInfo,
    objectTypeField: keyof DatabaseInfo
  ): Promise<TableInfo | ViewInfo | ProcedureInfo | FunctionInfo | TriggerInfo>;
  analyseSingleTable(pool: any, name: NamedObjectInfo): Promise<TableInfo>;
  getVersion(pool: any): Promise<{ version: string }>;
  listDatabases(
    pool: any
  ): Promise<
    {
      name: string;
    }[]
  >;
  analyseFull(pool: any): Promise<DatabaseInfo>;
  analyseIncremental(pool: any, structure: DatabaseInfo): Promise<DatabaseInfo>;
}