JetBrains / JetBrains/Exposed

How get reverse field by ``Entity`` property

Open
#1,346 4 comments 0 reactions 0 assignees View on GitHub
Dominant language
Kotlin
Stars
9.3k
Forks
798
Avg merge
4d 2h
Merged PRs (30d)
26

Description

```kotlin
object Posts : IntIdTable() {
val title = varchar("title", 50)
val content = text("content")
val author = reference("author", Users)
}

class Post(id: EntityID) : IntEntity(id) {
companion object : IntEntityClass(Posts)

var title by Posts.title
var content by Posts.content
var author by User referencedOn Posts.author
}

object Users : IntIdTable() {
val username = varchar("username", 50).uniqueIndex()
val email = varchar("email", 50).uniqueIndex()
}

class User(id: EntityID) : IntEntity(id) {
companion object : IntEntityClass(Users)

var username by Users.username
var email by Users.email
val posts by Post referrersOn Posts.author
}
```

Some example code was written above.

I searched issues, but there exist no results of same kind of question.

In this example, How get ``Posts::author``of ``User::posts`` by ``User::posts`` .

Please providing some example about ``User::posts`` api.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.