Associations

VaeQL automatically wires up Association fields (single or multi) for ease of use. You can traverse into and up from an association just as you would any other field. For example, if you had a collection called Properties that had an association to an Agent, you can grab the agent's name just by traversing:

<v:collection path="properties">
 Property name: <v:text path="name" />
 Offered by: <v:text path="agent/name" />
</v:collection>

Once you traverse into an association you are inside of that context. This means that if you traverse back up, you will go back up to the parent of the associated structure, not back into your original context. For example, say that Agents is actually a children of another collection called Branches. You could do this:

<v:collection path="properties">
 Property name: <v:text path="name" />
 Offered by: <v:text path="agent/name" />
 From this branch: <v:text path="agent/../name" />
</v:collection>

Multiple-item associations work the same way, except that since there are many associated entries, you will want to treat them like a collection:

<v:collection path="properties">
 Similar properties:
 <v:collection path="similar_properties">
  <v:text path="name" />
 </v:collection>
</v:collection>

Single-item associations can also be used in reverse. Going back to our Properties and Agents example, this is how you would list all properties offered by an Agent:

<!-- in Agent context -->
Agent name: <v:text path="name" />
<v:collection path="properties">
 Property name: <v:text path="name" />
</v:collection>

Note that in this case, there is no structure properties defined on agent. VaeQL checks for that first, and since it doesn't exist, checks to see if there is another collection called properties with an association to the current agent – which is the case here.