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 |
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 |
asJson()
Use this to convert to a simple javascript object, suitable for JSON.
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 |