I have two collections with users and another with jobs.
Users Collection:
{
"ref": Ref(Collection("users"), "365794904000954449"),
"ts": 1685108055020000,
"data": {
"name": "srinivas",
"location": "sattenapalli"
}
}
Jobs Collection:
{
"ref": Ref(Collection("jobs"), "366712312325734481"),
"ts": 1685982963785000,
"data": {
"name": "srinivas",
"Job": "Senior Architect"
}
}
I want to finally retrieve the data by joining the above two collection documents by the field name and the output should be an object with name,job and location.
Your question is asked in reference to a prior version of Fauna's query language, so I'll answer in Fauna's current, and far more easy to use version, FQL v10. This query will work on your existing dataset, even if you created it with v4
In your example, you are establishing a foreign key relationship between a Job object and a User object. Creating this relationship is very easy in v10
Fauna autoresolves relationships. So when you project the user field, the entire document is returned, completing the join
Here is an example where I am only interested in projecting specific fields. Again, the relationship is automatically resolved for you