Return reference as object instead of array
When building Enterspeed schemas you have almost full control over the output you return to the views. However, there are cases when working with references where you don’t have that full control. To address this, we've now introduced a first
function.
When you use the children
or filter
function while building a reference, these functions can return multiple references and because of that the result is an array. But sometimes, you only need the first child, or your filter query includes a comparison on an ID field, and you expect just one reference. In such cases, you probably want the result as an object instead of an array with a single item. This is now possible by using the new first
function.
The first
function returns the first item in the result set. The item is returned as an object instead of an array with one item. If no items are found null
is returned.
Read more about the first
function on the Enterspeed docs site.