Hi,
I have a Collection: maps with documents like this:
{
"ref": Ref(Collection("maps"), "328843776032243783"),
"ts": 1649868713320000,
"data": { "mapId": 12322 }
}
and a unique index:
{
name: "all_maps_mapId",
unique: true,
serialized: true,
source: "maps",
values: [
{
field: ["data", "mapId"],
reverse: true
}
]
}
I want a UDF to extract the first value from this index (i.e. the maximum mapId) in the most efficient way. Here’s what I have so far for my function body:
Query(
Lambda(
[],
Select(
[0],
Select("data", Paginate(Match(Index("all_maps_mapId")), { size: 1 }))
)
)
)
Is there a better (faster, more elegant, etc…) way to accomplish this? I tried using the built-in function Take, but it needs an array…
Thanks!