Skip to main content
Seasoned ⭐️⭐️⭐️
May 24, 2024 1:00 PM UTC
Solved

What happens to the container or indexes or during query for a field that has @reversedirectrelation

What happens to the container or indexes or during query for a field that has @reversedirectrelation.

Kindly point to the documentation that explains what actually happens internally when a field has @reversedirectrelation.

Practitioner ⭐️⭐️⭐️
Jul 2, 2024 3:52 PM UTC

Hi @Shreyas Mehta , a reverseDirectRelation directive specifies that a property is another type of connection definition i.e. similar to an edge connection definition. Meaning that it does not point to a property in the corresponding view's container itself. Instead it references a property in another View/Container that is expected to point towards the parent View of the reverseDirectRelation property.

ViewA {
propA: String # maps to ContainerA/propA
propB: ViewB # DirectRelation, maps to ContainerA/propB
propC: [ViewB] # Connection definition for edges, no container property underneath
}

ViewB {
propD: String # maps to ContainerB/propD
propE: [ViewA] @reverseDirectRelation(throughProperty='propB') # Connection definition for a reverse direct relation. Basically defines a way to automatically query ViewA nodes whose 'propB' property point towards ViewB nodes.
}

Since these are not physical properties (on Containers), indexes do not apply here. Instead, to gain performance, indexing should be applied to the property that IS the direct relation itself i.e. propB above.

Hope that clarifies it somewhat.

6 replies

Dilini Fernando
Expert ⭐️⭐️⭐️⭐️
Expert ⭐️⭐️⭐️⭐️
May 27, 2024 10:21 AM UTC

Hi @Shreyas Mehta,

Please add a comment if you have further questions after referring to this documentation.

Dilini Fernando
Expert ⭐️⭐️⭐️⭐️
Expert ⭐️⭐️⭐️⭐️
Jun 7, 2024 7:09 AM UTC

Hi @Shreyas Mehta,

Did the above information help you?  

Dilini Fernando
Expert ⭐️⭐️⭐️⭐️
Expert ⭐️⭐️⭐️⭐️
Jun 24, 2024 10:55 AM UTC

Hi @Shreyas Mehta,

As of this moment, I am officially closing the discussion on this particular topic. You are more than welcome to initiate a new post should you have any further questions or require additional information.

Seasoned ⭐️⭐️⭐️
Jul 2, 2024 12:39 PM UTC

@Dilini Fernando - The documentation doesn’t answer my question. Request you to get the answer from the product team.

Practitioner ⭐️⭐️⭐️
Jul 2, 2024 3:52 PM UTC

Hi @Shreyas Mehta , a reverseDirectRelation directive specifies that a property is another type of connection definition i.e. similar to an edge connection definition. Meaning that it does not point to a property in the corresponding view's container itself. Instead it references a property in another View/Container that is expected to point towards the parent View of the reverseDirectRelation property.

ViewA {
propA: String # maps to ContainerA/propA
propB: ViewB # DirectRelation, maps to ContainerA/propB
propC: [ViewB] # Connection definition for edges, no container property underneath
}

ViewB {
propD: String # maps to ContainerB/propD
propE: [ViewA] @reverseDirectRelation(throughProperty='propB') # Connection definition for a reverse direct relation. Basically defines a way to automatically query ViewA nodes whose 'propB' property point towards ViewB nodes.
}

Since these are not physical properties (on Containers), indexes do not apply here. Instead, to gain performance, indexing should be applied to the property that IS the direct relation itself i.e. propB above.

Hope that clarifies it somewhat.

Seasoned ⭐️⭐️⭐️
Jul 2, 2024 4:26 PM UTC

Thanks Uzair for the explanation.