UNPKG

ng-db-helper

Version:

Simple db helper for typescript like an orm with plugable connectors.

94 lines (93 loc) 3.48 kB
import { DataModel } from 'ts-db-helper'; import { Observable } from 'rxjs/Observable'; import 'rxjs/add/observable/combineLatest'; import 'rxjs/add/observable/concat'; /** * @class WebsqlConnectorConfiguration * * @description * This class is a default configuration for connector {@link WebsqlConnector} * It provides config key to add copy informations. * * @example * ```typescript * const config = new WebsqlConnectorConfiguration(); * // configure db name on device * config.dbName = app.sqlite; * // add config to connector * const connector = WebsqlConnector(config); * // add your connector to module configuration * ``` * * @author Olivier Margarit * @since 0.1 */ export declare class WebsqlConnectorConfiguration { /** * @public * @property {string} dbName file name of the database on the device */ dbName: string; /** * @public * @method initDataModel is called if database need to be initialized. * You can override this method if you need to add your logic * * @param {DataModel} dataModel model generated be model annotations * @param {Database} db @see WebSQL * * @return {Observable<any>} observable to subscribe during async operation */ initDataModel(dataModel: DataModel, db: any): Observable<any>; /** * @public * @method upgradeDataModel is called if version should be upgrade. * Default script create new table but does not alter existing table. * You can override this method to add your own logic like alteration * and let script create new table by calling super. * * @param {DataModel} dataModel model generated be model annotations * @param {Database} db @see WebSQL * * @return {Observable<any>} observable to subscribe during async operation */ upgradeDataModel(dataModel: DataModel, db: any): Observable<any>; /** * @private * @method createTables create table linked to datamodel (not table alteration) * * @param {DataModel} dataModel model generated be model annotations * @param {Database} db @see WebSQL * @param {boolean} doDrop drop table to allow recreation of database * * @return {Observable<any>} observable to subscribe during async operation */ private createTables(dataModel, db, doDrop?); /** * @private * @method dropTables a simmple method to drop all table in the data model * @param {DataModel} dataModel model generated be model annotations * @param {Database} db @see WebSQL * * @return {Observable<any>} observable to subscribe during async operation */ private dropTables(dataModel, db); /** * @private * @method dropTable drop table if exists * * @param {string} tableName name of the table to drop * @param {SQLTransaction} transaction @see WebSQL * * @return {Observable<any>} observable to subscribe during async operation */ private dropTable(tableName, transaction); /** * @private * @method query fire sql query * * @param query sql query * @param transaction SQLTransaction object, see websql documentation */ private query(query, transaction); }