I am new to faunadb. I am having trouble with querying data from two collections. I have a user collection with the following data.
{
"ref": Ref(Collection("users"), "286520131377445052"),
"ts": 1609505740440000,
"data": {
"userId": "f35fdc8d-6197-4d19-bf27-256bd41b3751",
"name": "PRANTA Dutta",
"email": "pranta@email.com",
"role": "borrower",
"password": "somepassword"
}
}
Then I have a loan collection with the following data
{
"ref": Ref(Collection("loans"), "287038065061397005"),
"ts": 1609999680495000,
"data": {
"monthlyInstallment": 473.33,
"loanDuration": 6,
"interestRate": 7,
"amount": 2000,
"modifiedMonthlyInstallment": 513.33,
"mode": "processing",
"userId": "f35fdc8d-6197-4d19-bf27-256bd41b3751"
}
}
Important: Loans and Users Collection have a one to many relations and a user can request multiple loans.
Now I want to write a query to fetch the loan data with matching userId at once so I can show all the data altogether.
The Data I want is the following:
"data": {
"monthlyInstallment": 473.33,
"loanDuration": 6,
"interestRate": 7,
"amount": 2000,
"modifiedMonthlyInstallment": 513.33,
"mode": "processing",
"userId": "f35fdc8d-6197-4d19-bf27-256bd41b3751",
{
"data": {
"userId": "f35fdc8d-6197-4d19-bf27-256bd41b3751",
"name": "PRANTA Dutta",
"email": "pranta@email.com",
"role": "borrower",
"password": "somepassword"
}
}
}
How can I do that using FQL, Thanks in Advance.