ts-db-helper
Version:
Simple ORM based on TypeScript
57 lines (56 loc) • 1.79 kB
TypeScript
import { DbHelperModel } from '../db-helper-model.model';
import { QueryResult } from '../../interfaces/query-result.interface';
/**
* @private
* @class ModelResult
*
* @description
* This class is private part of the API.
* A specific wrapper to convert QueryResult to typed QueryResult on demand
*
* @param T @extends {@link DbHelperModel}, a model declared with table and
* column annotations
*
* @author Olivier Margarit
* @since 0.1
*/
export declare class ModelResult<T extends DbHelperModel> implements QueryResult<T> {
private result;
private model;
private projection;
/**
* @private
* @property {Array<T>} cache array of converted model. Only keep getted model as cache
*/
private cache;
/**
* @public
* @property {number} rowsAffected serve real ResultQuery rowsAffected;
*/
readonly rowsAffected: number;
/**
* @public
* @property {number} insertId serve real ResultQuery insertId;
*/
readonly insertId: number | undefined;
/**
* @public
* @property {Object} rows serve customized type ResultQuery rows;
*/
readonly rows: {
length: number;
item: (i: number) => T;
toArray: () => T[];
};
/**
* @public
* @constructor this is a private API and should not be available for integrators
*
* @param {QueryResult<any>} result the real QueryResult converted to return typed models
* @param {{new(): T}} model the target model to convert
* @param {Array<string>} projection the optional projection
*/
constructor(result: QueryResult<any>, model: {
new (): T;
}, projection?: string[] | undefined);
}