I'm fairly new to Fauna so please forgive me. I'd like to make one query that returns a nested document within a document. I access the initial document that contains the nested document by the index I created below:
Get(Match(Index("account-user_by_sub"), "google-oauth2|10233470761")
That index returns this:
{
ref: Ref(Collection("account-users"), "325230990747238466"),
ts: 1646423292780000,
data: {
userAccount: Ref(Collection("user-accounts"), "325134359745003585"),
firstName: "firstName",
lastName: "lastName",
sub: "google-oauth2|10233470761",
}
}
I'd like to make one query that returns the above response along with the nested userAccount document. I found similar questions on Stackoverflow but didn't have any luck with their solutions. I tried this below but it just returned the block of code you see above:
Get(Match(Index("account-user_by_sub"), "google-oauth2|10233470761")),
Lambda("X",
Let(
{
accountUserDoc: Get(Var("X")),
userAccountRef: Get(Select(["data", "userAccount"], Var("accountUserDoc")))
},
{
accountUser: Var("accountUserDoc"),
userAccount: Get(Var("userAccountRef"))
}
)
)