properties method is where you define the output that goes into the view you fetch from the Delivery API
Properties example
PropertiesContext object
ThePropertiesContext object is passed into the properties method and gives you access to a set of methods described below.
Methods
lookup
Lookup source entities. Lookup allows you to search source entities using a filter string and work with the data from the source entities directly in the schema. Note thelookup is an async function so you have to use async/await when you are using the lookup function.
lookup(filter)
The
lookup function is limited to a maximum number of items to return, based on the tenant plan. It can however be increased per tenant basis. Please reach out to Enterspeed if needed.The default limits are:- Free & Premium plans: 100 items
- Enterprise plan: 500 items
Parameters
Required function calls
After thelookup function it’s required to call toPromise to excecute the query and return a promise.
toPromise
toPromise
Using the toPromise function excecutes the query and return a promise you must resolve.
look toPromise
Optional function calls
To filter the source entities even further you can call some of the following optional functions.limit
limit
orderBy
orderBy
sourceGroup
sourceGroup
The sourceGroup function lets you specify the source group. By default the source group of the current source entity is used.
Parameters
If not defined, it uses the current source group.
lookup and sourceGroup
Examples
lookup with async/await
lookup without custom properties
partial
Referencing a partial schema. The partial mapping property type allows for dynamically including partial schemas into the main schema. This is useful when you need to iterate an array of different objects that has an identifier, like an ID, alias or similar.partial(schemaAlias, input)
Parameters
Examples
partial
passing extra properties to the partial schema
input defines what goes into the partial schema and can be any custom object, and the schemaAlias is used to resolve what partial schema to use. So, in this case, we could have a partial schema with an alias: block-headline.
reference
Thereference are used to reference other views created from either this source entity or another source entity.
When referenced, Enterspeed will resolve the view when requested by the Delivery API so that the data will stay up-to-date if a reference view is updated.
The reference function is the starting point where you can use our fluent API to configure the reference(s) you want (by filter, by originId, take only top 5, and so on).
reference(schemaAlias)
Parameters
Required function calls
After thereference function it’s required to call one of the following functions to define what source entities you want references to.
byOriginId
byOriginId
Using the byOriginId function lets you create a reference to a source entity by its oringinId.
Parameters
reference by byOriginId
byOriginIds
byOriginIds
Using the byOriginIds function lets you create a references to a list of source entity by their oringinId.
Parameters
reference by byOriginIds
children
children
The children function creates a reference to all the children of the current source entity. It’s basicly a shortcut for
.filter("originParentId eq '{sourceEntity.properties.originId}'").reference by children
reference by children and type
The
children function is limited to a maximum number of items to return, based on the tenant plan. It can however be increased per tenant basis. Please reach out to Enterspeed if needed.The default limits are:- Free & Premium plans: 100 items
- Enterprise plan: 500 items
filter
filter
Using the filter function lets you do a dynamic search for source entities you want to make references to.
Parameters
reference by filter
The
filter function is limited to a maximum number of items to return, based on the tenant plan. It can however be increased per tenant basis. Please reach out to Enterspeed if needed.The default limits are:- Free & Premium plans: 100 items
- Enterprise plan: 500 items
parent
parent
The parent function creates a reference to the parent of the current source entity. It’s basicly a shortcut for
.filter("originId eq '{sourceEntity.properties.originParentId}'").reference by parent
self
self
The self method creates a reference to a view created by the specified schema on the current source entity. The helper method is equivalent to calling
.byOriginId(sourceEntity.originId).reference by self
Optional function calls
To filter the source entities you are making references to even further you can call some of the following optional functions.limit
limit
orderBy
orderBy
sourceGroup
sourceGroup
The
sourceGroup function lets you specify the source group. By default the source group of the current source entity is used.Parameters
If not defined, it uses the current source group.
reference by filter and sourceGroup
first
first
The
first function return the first item in the result set. The item i returned as an object instead of an array with one item.The function must always be called as the last call in the chain.reference to the first news teaser
Examples
Property type: reference (static value) with originId
reference by filter and sourceGroup
schemaAlias can either be a static value, like “seo”, or it can be a dynamic value being resolved from the Source Entity that is being processed by Enterspeed. This allows for supporting almost any use case.
Reference response
The response of references differs in V1 and V2+ of the delivery API. V1 return the id, type and wraps the properties from the referenced view in aview property. The response of references in V2+ is much cleaner and only returns the actual properties from the referenced schema. If a reference is not found in V2+, the reference information is added in the missingViewReference property in the meta object for debugging purpose.
Delivery API V1 uses a nested view property
Delivery API V2+ only returns the actual view properties