Skip to content

Nested/Embedded datastructures possible? #12

@alwins0n

Description

@alwins0n

Thank you for creating this!

Would it be possible to support nested or "embedded" case classes within a case class representation of a table?

non compiling example:

case class Customer[T[_]](
    name: T[String],
    address: T[Address[T[_]]]
)

object Customer extends Table[Customer]

case class Address[T[_]](
    street: T[String],
    city: T[String],
    zipCode: T[String],
    country: T[String]
)

the expected outcome in this case would be that the address value is treated as if it were flat in the customer table. this would allow sharing or reusing data structures in different contexts.

a probably better example, would be MonetaryAmount with a value and currency component. its used a lot in different places if an app commits to storing values with currency.

Maybe there is some way to hook into something like a CompositeTypeMapper where one can supply custom givens analogous to the TypeMapper typeclass

for reference, I asked a somewhat similar question in another repo: AugustNagro/magnum#24 obviously, it's tough for me to let go of that feature after years of using java's hibernate :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions