diff --git a/documentation-website/Writerside/topics/DAO-Relationships.topic b/documentation-website/Writerside/topics/DAO-Relationships.topic index 2edec2564b..5cedbe5427 100644 --- a/documentation-website/Writerside/topics/DAO-Relationships.topic +++ b/documentation-website/Writerside/topics/DAO-Relationships.topic @@ -52,7 +52,12 @@

You can implement this relationship by using a reference column in the child table - (UserRatingsTable) that links to the parent table (UsersTable): + (UserRatingsTable) that links to the parent table (UsersTable). To create a + reference column, use the + + reference() + + function:

@@ -82,8 +87,11 @@

If you wanted to get all the ratings for a film, you could do that by using the .find() - function of the entity class. However, it is much easier to add a referrersOn field to the - class representing the film, StarWarsFilmEntity: + function of the entity class. However, it is much easier to add a + + referrersOn + + field to the class representing the film, StarWarsFilmEntity:

- If each user rates only one film, you can define a backReferencedOn + If each user rates only one film, you can define a + + backReferencedOn + field to the entity class to access the UserRatingsTable data:

In Exposed, you can also add an optional reference.

For example, if you want to include anonymous user ratings to your table, you can do so by setting - the reference field as optional using optReference() in your table and - optionalReferencedOn in your entity definition: + the reference field as optional using + + optReference() + + in your table and + + optionalReferencedOn + + in your entity definition:

@@ -150,8 +168,8 @@ src="exposed-dao-relationships/src/main/kotlin/org/example/entities/UserEntity.kt" include-lines="23-27,37-41" /> -

Without using the infix notation, the orderBy method is chained - after referrersOn:

+

Without using the infix notation, + the orderBy method is chained after referrersOn:

-

Add a reference to the ActorEntity in the StarWarsFilmEntity using the - via keyword:

+

+ Add a reference to the ActorEntity in the StarWarsFilmEntity using the + + via + + function: +

- Then, add the field to the entity using the referencedOn function: + Then, add the field to the entity using the + + referencedOn + + function:

To eagerly load references on Collections of DAO's such as List - and SizedIterable, use the .with() function and pass - each reference as KProperty: + and SizedIterable, use the + + .with() + + function and pass each reference as KProperty:

- To make content available outside the transaction, use the eagerLoading + To make content available outside the transaction, use the + + eagerLoading + parameter in your field definition: