I’m currently migrating a database to fauna, one of my collections has a notificationtime
field, which is of type Time
. I’ve uploaded this data with the JS client without errors, but I’m now having trouble querying this collection and sorting by that field. There are many times in my app where I’d just like to grab the most recent notification.
I’ve created an index on this collection like so:
CreateIndex({
name: "milonEventsByTime",
source: Collection("VehicleMilonData"),
terms: [{ field: ["data", "notificationtime"] }, { field: ["ref"] }]
})
I’ve also added this resolver to my datamodel:
allMilonEventsSortedByTime: [VehicleMilonData] @resolver(name: "milonEventsByTime", paginated: true)
And finally, have created this UDF:
Query(
Lambda(
["size", "after", "before"],
Let(
{
match: Match(Index("milonEventsByTime")),
page: If(
Equals(Var("before"), null),
If(
Equals(Var("after"), null),
Paginate(Var("match"), { size: Var("size") }),
Paginate(Var("match"), { after: Var("after"), size: Var("size") })
),
Paginate(Var("match"), { before: Var("before"), size: Var("size") })
)
},
Map(Var("page"), Lambda("values", Get(Select(4, Var("values")))))
)
)
)
But when querying the dataset with that function I get no results:
I’ve followed the various indexing and sorting pages in the docs and in this forum, but I’m really struggling to get any further from here and would love some advice.