UNPKG

@herlinus/coloquent

Version:

Library for retrieving model objects from a JSON-API, with a fluent syntax inspired by Laravel Eloquent.

33 lines 1.66 kB
import { Relation } from "./Relation"; import { Builder } from "../Builder"; export class ToOneRelation extends Relation { get(page) { return new Builder(this.getType(), this.getName(), this.getReferringObject().getJsonApiType(), this.getReferringObject().getApiId(), true) .get(page); } first() { return new Builder(this.getType(), this.getName(), this.getReferringObject().getJsonApiType(), this.getReferringObject().getApiId(), true) .first(); } find(id) { return new Builder(this.getType(), this.getName(), this.getReferringObject().getJsonApiType(), this.getReferringObject().getApiId(), true) .find(id); } where(attribute, value) { return new Builder(this.getType(), this.getName(), this.getReferringObject().getJsonApiType(), this.getReferringObject().getApiId(), true) .where(attribute, value); } with(value) { return new Builder(this.getType(), this.getName(), this.getReferringObject().getJsonApiType(), this.getReferringObject().getApiId(), true) .with(value); } orderBy(attribute, direction) { return new Builder(this.getType(), this.getName(), this.getReferringObject().getJsonApiType(), this.getReferringObject().getApiId(), true) .orderBy(attribute, direction); } option(queryParameter, value) { return new Builder(this.getType(), this.getName(), this.getReferringObject().getJsonApiType(), this.getReferringObject().getApiId(), true) .option(queryParameter, value); } } //# sourceMappingURL=ToOneRelation.js.map