Hi,
I have a database of beer types. Carslberg, Heineken etc. The beers only have two properties: “name” and “alcohol”. So a beer document would look like
{
"ref": Ref(Collection("beers"), id),
"ts": ...,
"data": {
"name": "Carlsberg",
"alcohol": "5,2%"
}
}
I want to write a FQL query that fetches the content of the data field - the data object - and that includes the ref’s ID with it. Is this such a rare situation? I find almost no examples online of that. Playing around in the dashboard’s shell I managed to solve it for now like this:
Merge(
{ id: Select(
["ref", "id"],
Get(Match(Index("beer_by_name"), "Carlsberg"))
)},
Select(
["data"],
Get(Match(Index("beer_by_name"), "Carlsberg"))
)
)
But it feels awkward and complex for such a small, normal task to do, no? What am I missing? It should be way easier shouldn’t it? Does anybody know of an easier way? My end goal is just to have my API return the beer entity with the ID included.
Thanks in advance