Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Map several classes to single entity collection #70

Open
d-r-q opened this issue Feb 17, 2020 · 0 comments
Open

Map several classes to single entity collection #70

d-r-q opened this issue Feb 17, 2020 · 0 comments

Comments

@d-r-q
Copy link
Owner

d-r-q commented Feb 17, 2020

The general idea is following

First of all, allow user to create several classes with different fields mapped to the same entity collection:

data class User(val id: Long?)

data class UserExt(val id: Long?, val name: String, val father: User, val mother: User) : User(id)

And then allow user to define refs in schema definition:

schema {
    entity(UserExt::class) {
        ref(User::class)
    }
}

And finally allow user to express adhoc query:

// select only user, all ref fields fetched as refs by default
val user = query<UserExt>(UserExt::name eq "user")
assertTrue(user.father is User)
assertTrue(user.mother is User)

// select user and his father
val queryGraph = root(UserExt::class) {
    UserExt::father fetchAs UserExt::class
}
val userWithFather = query<UserExt>(UserExt::name eq "user")
assertTrue(user.father is User)
assertTrue(user.mother is UserId)

Motivation: provide user simple way to express exact form required entites graph

Problems/questions:

  1. Recursive types

Relates to: #51

@d-r-q d-r-q added this to the Backlog milestone Feb 17, 2020
@d-r-q d-r-q mentioned this issue Mar 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant