agrosner / DBFlow

A blazing fast, powerful, and very simple ORM android database library that writes database code for you.
MIT License
4.87k stars 598 forks source link

[Question] Get relationship info of a table #1646

Closed 3dmg closed 3 years ago

3dmg commented 5 years ago

DBFlow Version: 4.2.4

Question:

Hi, we use the ForeignKey annotation to create the relationship between tables, like this:

@Table(database = MyDb::class)
class Group : BaseModel() {

    @Column
    @ForeignKey(tableClass = Team::class, onUpdate = ForeignKeyAction.CASCADE, onDelete = ForeignKeyAction.CASCADE)
    @SerializedName("team_id")
    @Expose
    var teamId: Long? = null
    ...

Is it possible to get this info later in code? The info would be: Has the table Group a relationship with another table -> when yes, with which table and which id?

Thanks in advance!

agrosner commented 3 years ago

not currently with the library. You can with SQLite look at table info: https://www.sqlitetutorial.net/sqlite-tutorial/sqlite-describe-table/