mirror of
https://github.com/jlengrand/exposed-wiki.git
synced 2026-03-10 08:11:18 +00:00
Update optional relation's examples using optionalReferrersOn (#14)
Update optional relation's examples using optionalReferrersOn
This commit is contained in:
13
DAO.md
13
DAO.md
@@ -152,8 +152,17 @@ class UserRating(id: EntityID<Int>): IntEntity(id) {
|
||||
...
|
||||
}
|
||||
```
|
||||
Now `secondUser` will be a nullable field.
|
||||
Of course, you can still use `referrersOn`.
|
||||
Now `secondUser` will be a nullable field, and you should use `optionalReferrersOn` instead of `referrersOn` to get all the ratings for a `secondUser`.
|
||||
|
||||
```kotlin
|
||||
class User(id: EntityID<Int>): IntEntity(id) {
|
||||
companion object : IntEntityClass<User>(Users)
|
||||
...
|
||||
val secondRatings by UserRating optionalReferrersOn UserRatings.secondUser // make sure to use val and optionalReferrersOn
|
||||
...
|
||||
}
|
||||
```
|
||||
|
||||
### many-to-many reference
|
||||
In some cases, a many-to-many reference may be required.
|
||||
Let's assume you want to add a reference to the following Actors table to the StarWarsFilm class:
|
||||
|
||||
Reference in New Issue
Block a user