ts-db-helper
Version:
Simple ORM based on TypeScript
89 lines (88 loc) • 2.94 kB
TypeScript
import { CompositeClause } from './composite-clause.model';
import { DbHelperModel } from '../db-helper-model.model';
import { QueryResult } from '../../interfaces/query-result.interface';
import { Observable } from 'rxjs/Observable';
import { DbQuery } from '../db-query.model';
import { ClauseGroup } from './clause-group.model';
import { Clause } from './clause.model';
/**
* @public
* @class QueryDelete
*
* @description
* For design reasons this class should not be used directly. Use this class through {@link Delete} function.
*
* @param T @extends DbHelperModel a model declared with table
* and column annotations
*
* @example
* ```typesrcript
* // Delete a specific model using Delete
* // assume that "todo" is declared before and is a model extending
* // DbHelperModel and using Table + Column annotation
* Delete(todo).exec().subscribe((qr: QueryResult<any>) => {
* // the model is deleted...
* }, (err) => {
* // manage th error...
* });
* // You could use Delete statement to delete many entries
* Delete(Todo).where({isDone: true}).exec().subscribe((qr: QueryResult<any>) => {
* // all done todos are deleted !
* }, (err) => {
* // manage th error...
* });
* ```
*
* @author Olivier Margarit
* @since 0.1
*/
export declare class QueryDelete<T extends DbHelperModel> {
private model;
/**
* @private
* @constant {string} type the type of statement, should not be modified
*/
private readonly type;
/**
* @private
* @property {ClauseGroup} whereClauses is {@link ClauseGroup} instance containing
* where clauses
*/
private whereClauses;
/**
* @public
* @constructor should not be use directly, see class header
*
* @param {T | {new(): T }} model DbHelperModel extention
*/
constructor(model: T | {
new (): T;
});
/**
* @public
* @method where is the method to add clauses to the where statement of the query
* see {@link Clause} or {@link ClauseGroup}
*
* @param {Clause|Clause[]|ClauseGroup|CompositeClause|{[index: string]: any}} clauses list of clauses
*
* @return {QueryDelete<T>} this instance to chain query instructions
*/
where(clauses: Clause | Clause[] | ClauseGroup | CompositeClause | {
[index: string]: any;
}): QueryDelete<T>;
/**
* @public
* @method build should be removed to be a part of the private API
*
* @return {DbQuery} of the query with the string part and
* clauses params.
*/
build(): DbQuery;
/**
* @public
* @method exec to execute the query and asynchronously retreive result.
*
* @return {Observable<QueryResult<any>>} observable to subscribe and retrieve results
*/
exec(): Observable<QueryResult<any>>;
}