Skip to content

ModelService

Mihael Safaric edited this page Feb 20, 2019 · 6 revisions

Your resource services must extend ModelService. ModelService gives a communication interface for HTTP requests.

constructor(protected datastore: DatastoreService, private modelClass: {new(...args): Model });

Methods

findOne

findOne(modelId: string, requestOptions: RequestOptions = {}): Observable<Model>;
  • modelId: string

  • requestOptions: RequestOptions

    • optional
    • additional request options

find

find(params: object): Observable<Array<Model>>;
find(params: object, includeMeta: boolean): Observable<Array<Model>>;
find(params: object, includeMeta: boolean, requestOptions: RequestOptions): Observable<HalDocument<Model>>;
  • params: object

    • optional
    • parameters which will be send in the reqest
  • includeMeta: boolean

    • optional
    • if omitted or falsy, Observable<Array<Model>> is returned
    • if truthy, Observable<HalDocument<Model>> is returned (see HalDocument)
  • requestOptions: RequestOptions

    • optional
    • additional request options

createNewModel

createNewModel(recordData: object = {}): Model
  • locally creates an instance of a model class which is passed through the constructor, modelClass
  • NOTE: it does not tigger saving of newly created model