2018-01-14 16:32:04 +00:00
|
|
|
import * as plugins from "./smartdata.plugins";
|
|
|
|
import { Objectmap } from "lik";
|
|
|
|
import { DbTable } from "./smartdata.classes.dbtable";
|
|
|
|
import { ConnectionOptions } from "rethinkdb";
|
2017-07-15 22:11:03 +00:00
|
|
|
/**
|
|
|
|
* interface - indicates the connection status of the db
|
|
|
|
*/
|
2018-01-14 16:32:04 +00:00
|
|
|
export declare type TConnectionStatus = "initial" | "disconnected" | "connected" | "failed";
|
2017-07-15 22:11:03 +00:00
|
|
|
export declare class Db {
|
2018-01-07 17:10:16 +00:00
|
|
|
dbName: string;
|
|
|
|
connectionOptions: plugins.rethinkDb.ConnectionOptions;
|
2018-01-07 16:26:34 +00:00
|
|
|
dbConnection: plugins.rethinkDb.Connection;
|
2017-07-15 22:11:03 +00:00
|
|
|
status: TConnectionStatus;
|
2018-01-07 17:10:16 +00:00
|
|
|
dbTablesMap: Objectmap<DbTable<any>>;
|
|
|
|
constructor(connectionOptionsArg: ConnectionOptions);
|
2018-01-12 00:22:58 +00:00
|
|
|
/**
|
2018-01-14 16:32:04 +00:00
|
|
|
* supply additional SSl options needed to connect to certain Rethink DB servers (e.g. compose.io)
|
2018-01-12 00:22:58 +00:00
|
|
|
*/
|
2018-01-14 16:32:04 +00:00
|
|
|
setSsl(certificateStringArg: string, formatArg: "base64" | "clearText"): void;
|
2017-07-15 22:11:03 +00:00
|
|
|
/**
|
|
|
|
* connects to the database that was specified during instance creation
|
|
|
|
*/
|
|
|
|
connect(): Promise<any>;
|
|
|
|
/**
|
|
|
|
* closes the connection to the databse
|
|
|
|
*/
|
|
|
|
close(): Promise<any>;
|
2018-01-14 16:32:04 +00:00
|
|
|
addTable(dbTableArg: DbTable<any>): void;
|
2017-07-15 22:11:03 +00:00
|
|
|
/**
|
2018-01-07 17:10:16 +00:00
|
|
|
* Gets a table's name and returns smartdata's DbTable class
|
|
|
|
* @param nameArg
|
|
|
|
* @returns DbTable
|
2017-07-15 22:11:03 +00:00
|
|
|
*/
|
2018-01-07 17:10:16 +00:00
|
|
|
getDbTableByName<T>(nameArg: string): Promise<DbTable<T>>;
|
2017-07-15 22:11:03 +00:00
|
|
|
}
|