From 351bcbfaba059d23c26092001a589e7cbff1f017 Mon Sep 17 00:00:00 2001 From: Yossi Kolesnicov Date: Tue, 24 Jul 2018 23:27:25 +0300 Subject: [PATCH] Some more typing, formatting documentation --- .gitignore | 2 ++ lib/entity/entity-field.config.ts | 6 +++++- lib/services/paris.ts | 4 +++- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index c36cdd9..61c9e6e 100644 --- a/.gitignore +++ b/.gitignore @@ -65,3 +65,5 @@ package-lock.json # Build output bundle/ dist/ + +.idea diff --git a/lib/entity/entity-field.config.ts b/lib/entity/entity-field.config.ts index a9f6fcf..1bdab2e 100644 --- a/lib/entity/entity-field.config.ts +++ b/lib/entity/entity-field.config.ts @@ -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 Using '__self' for data to pass the whole raw data + * @example Using '\_\_self' for data to pass the whole raw data * 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, diff --git a/lib/services/paris.ts b/lib/services/paris.ts index d5b1c4b..ecf09b5 100644 --- a/lib/services/paris.ts +++ b/lib/services/paris.ts @@ -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> = new Map; @@ -379,7 +381,7 @@ export class Paris{ * @param {{[p: string]: any}} params * @returns {Observable} */ - getItemById(entityConstructor:DataEntityConstructor, itemId: string | number, options?:DataOptions, params?:{ [index:string]:any }): Observable{ + getItemById(entityConstructor:DataEntityConstructor, itemId: TId, options?:DataOptions, params?:{ [index:string]:any }): Observable{ options = options || defaultDataOptions; let repository:Repository = this.getRepository(entityConstructor);