Class

Entity

Entity

Entities are the prefered way to store structured information about a topic. Entities are a very powerful concept in the Quintype eco-system, and can be used to model many real world concepts such as Magazines, People, Organisations, or Cities.

Stories and Collections can be associated with Entities, and Entities can also be associated with each other.

Most entities have a type, which represents the schema of that entity. As an example, an City may have a name, population, and be associated with a mayor (person).

import { Entity } from "@quintype/framework/server/api-client";

Methods

static getEntities(client, params) → {Array.<Entity>}

Fetches all entities that match a criteria

All of the following params are optional.

Example

const entities = await Entity.getEntities({
  type: "magazine"
})
showEntities(entities.map(e => e.asJson()))
Parameters:
Name Type Description
client Client
params Object

Parameters which are directly passed to the API

ids string

A comma seperated list of ids

type string

The type of the entity (default to all)

limit string

The maximum number of entities to return

offset string

A pagination offset

View Source index.js, line 712

Array.<Entity>

static getEntity(client, entityId, params) → {Promise.<(Entity|null)>}

Fetches an entity given it's Id.

Parameters:
Name Type Description
client Client
entityId number
params Object

Parameters which are directly passed to the API

View Source index.js, line 724

Promise.<(Entity|null)>

asJson()

Use this to convert to a simple javascript object, suitable for JSON.

View Source index.js, line 687

getCollections(client, params) → {Array.<Collection>}

This method returns all collections associated with an entity.

Example

const magazine = await Entity.getEntity(client, 42);
const issues = await magazine.getCollections(client, {
  limit: 6,
  "sort-by": "collection-date",
  "order": "desc"
})
Parameters:
Name Type Description
client Client
params Object

Params to pass to the API

View Source index.js, line 745

Array.<Collection>