Course lesson

Add a Product Relation to Shop to understand Document Model Relationship in Fauna

If you have been poking around the queries at this point in the course, you might notice that when you query for a product, you can get all the associated shop information. This is because we defined the @relation on the Shop property within Product. This...

Duration
2 min
Access
Free
Transcript
Retained from source evidence

If you have been poking around the queries at this point in the course, you might notice that when you query for a product, you can get all the associated shop information. This is because we defined the @relation on the Shop property within Product. This allowed Fauna to create an index behind the scenes to easily fetch this data.

We haven't done the same for the Product property on the Shop so we can't access the data. When we add a new @relation to Product we can then grab all the product information from shop queries that we like.

This is based on the Document Model Relationship in Fauna that you can read more about here.