Closed dxxvi closed 11 months ago
Yes; in this example SqlNameMapper.CamelToSnakeCase maps the class & field names from Camel case to Snake case:
@Table(PostgresDbType, SqlNameMapper.CamelToSnakeCase) case class User( @Id id: Long, firstName: Option[String], lastName: String, created: OffsetDateTime ) derives DbCodec
The corresponding sql table could be:
create table user ( id bigint primary key, first_name text, last_name text not null, created timestamptz not null );
There's other implementations of SqlNameMapper, and users can create their own as well.
To change individual columns you can use the @SqlName(String) annotation:
@SqlName(String)
@Table(PostgresDbType, SqlNameMapper.CamelToSnakeCase) @SqlName(config.schema + ".my_user") case class User( @Id id: Long, firstName: Option[String], @SqlName("usr_last_name") lastName: String, created: OffsetDateTime ) derives DbCodec
More documentation is in https://github.com/AugustNagro/magnum#immutable-repositories :)
Hi @dxxvi feel free to re-open if unresolved.
Yes; in this example SqlNameMapper.CamelToSnakeCase maps the class & field names from Camel case to Snake case:
The corresponding sql table could be:
There's other implementations of SqlNameMapper, and users can create their own as well.
To change individual columns you can use the
@SqlName(String)
annotation:More documentation is in https://github.com/AugustNagro/magnum#immutable-repositories :)