Some more typing, formatting documentation

This commit is contained in:
Yossi Kolesnicov 2018-07-24 23:27:25 +03:00
Родитель 8da26dc5d4
Коммит 351bcbfaba
3 изменённых файлов: 10 добавлений и 2 удалений

2
.gitignore поставляемый
Просмотреть файл

@ -65,3 +65,5 @@ package-lock.json
# Build output
bundle/
dist/
.idea

Просмотреть файл

@ -22,8 +22,10 @@ export interface FieldConfig{
*
* If an entity has the following property definition:
*
* ```typescript
* @EntityField()
* name:string;
* ```
*
* Then when creating the model, if the raw data contains a `name` property with value 'Anna', the resulting model will have a `name` property with value 'Anna'.
*
@ -47,7 +49,7 @@ export interface FieldConfig{
*
* Then the model's `date` property will have a value of Date(1532422166428), since both creation_date and init_date have no value in the data.
*
* @example <caption>Using '__self' for data to pass the whole raw data</caption>
* @example <caption>Using '\_\_self' for data to pass the whole raw data</caption>
* In the case when we want to separate some properties of the raw data to a sub-model, it's possible to use the special value '__self' for the `data` field configuration.
* This passes the whole raw data object to the field's creation, rather than just the value of a property. e.g:
* ```typescript
@ -61,6 +63,7 @@ export interface FieldConfig{
* ```
* In case we want to separate all address properties from a user into an encapsulated object, for the following raw data:
*
* ```json
* {
* "name": "Anna",
* "street": "Prinsengracht 263-267",
@ -68,6 +71,7 @@ export interface FieldConfig{
* "city": "Amsterdam",
* "country": "Holland"
* }
* ```
*/
data?:"__self" | string | Array<string>,

Просмотреть файл

@ -27,6 +27,8 @@ import {catchError, map, mergeMap, switchMap, tap} from "rxjs/operators";
import {DataTransformersService} from "./data-transformers.service";
import {DataCache, DataCacheSettings} from "./cache";
import * as _ from "lodash";
import {EntityModelBase} from "../models/entity-model.base";
import {EntityId} from "../models/entity-id.type";
export class Paris{
private repositories:Map<DataEntityType, IRepository<ModelBase>> = new Map;
@ -379,7 +381,7 @@ export class Paris{
* @param {{[p: string]: any}} params
* @returns {Observable<TEntity extends ModelBase>}
*/
getItemById<TEntity extends ModelBase>(entityConstructor:DataEntityConstructor<TEntity>, itemId: string | number, options?:DataOptions, params?:{ [index:string]:any }): Observable<TEntity>{
getItemById<TEntity extends EntityModelBase, TId extends EntityId = string>(entityConstructor:DataEntityConstructor<TEntity>, itemId: TId, options?:DataOptions, params?:{ [index:string]:any }): Observable<TEntity>{
options = options || defaultDataOptions;
let repository:Repository<TEntity> = this.getRepository(entityConstructor);