Very basic question but after playing with the docs and the shell I still can’t figure this out.
I have a collection , each document has a start_date
field (I receive this from an API) which is just an ISO timestamp like "2021-02-27T17:50:00Z"
I tried creating an index for this like so:
CreateIndex({name:'activities_by_time',source:Collection('activities'),values:[{field:['data', 'start_date']}]})
I try to retrieve the most recent document using
Paginate(Match(Index("activities_by_time")),{"size":1})
which returns:
{
after: [
"2021-02-27T18:50:00Z",
Ref(Collection("activities"), "291707100238709251")
],
data: ["2021-02-27T17:50:00Z"]
}
and if I increase the size to 2, I get:
{ data: ["2021-02-27T17:50:00Z", "2021-02-27T18:50:00Z"]}
So I’m getting back the field that the index is on, not the ref. So obviously if I add a Map
around this Paginate
I get an error.
Side note, but I’m just dumping these json objects into faunadb as I receive them via a webhook - will fauna just figure out that these are dates?