I’m trying to create an index that returns sorted data in an object with keys. The default index for my collection returns something like this:
{
"ref&
the short answer to your question is: "no there is not", but there are probably solutions to your problem (I'll need to better understand the problem you try to solve). Indexes will always return arrays of data since that's how they are structured and FaunaDB provides you access to the raw power of the index. We do not try to be clever and interpret what you might want.
(Disclaimer, I didn't test the code, it's 11:30 pm here so I'm almost going to log off :) but still wanted to help you)
That said, there are two options:
Map(
Paginate(Match(Index('your_index_name'))),
Lambda(['sort_date', 'title', 'post_type', 'status', 'ref'], Get(Var('ref')))
)
Map(
Paginate(Match(Index('your_index_name'))),
Lambda(['sort_date', 'title', 'post_type', 'status', 'ref'],
{
ref: Var('ref'),
sort_date: Var('sort_date'),
title: Var('title'),
post_type: Var('post_type'),
status: Var('status')
}
)
)
That should give you an array of objects instead :)