Skip to content

ModelService

Mihael Safaric edited this page Sep 4, 2019 · 6 revisions

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

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

Methods

findOne

findOne(modelId: string, includeRelationships: Array<string> = [], requestOptions: RequestOptions = {}, subsequentRequestsOptions: RequestOptions): Observable<Model>
  • modelId: string

  • includeRelationships

  • requestOptions: RequestOptions

    • optional
    • additional request options
    • those options will be used only for the main request, custom options for relationship calls can be set via subsequentRequestsOptions
  • subsequentRequestsOptions: RequestOptions

    • optional
    • additional options for relationship calls

find

find(params: object): Observable<Array<Model>>;
find(params: object, includeMeta: false): Observable<Array<Model>>;
find(params: object, includeMeta: true): Observable<HalDocument<Model>>;
find(params: object, includeMeta: boolean, includeRelationships: Array<string>, requestOptions: RequestOptions, subsequentRequestsOptions: 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
    • those options will be used only for the main request, custom options for relationship calls can be set via subsequentRequestsOptions
  • subsequentRequestsOptions: RequestOptions

    • optional
    • additional options for relationship calls

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