nodecosmos / charybdis

Rust ORM for ScyllaDB and Apache Cassandra
MIT License
128 stars 8 forks source link

Custom types for migrations #40

Closed norrchr closed 3 months ago

norrchr commented 3 months ago

Do you plan on adding some sort of support for custom types for migrations?

I think just the ability to map a custom type to a CqlType would be the easiest work around, maybe a field attribute?

`#[charybdis_model(...)] pub struct Example {

[charybdis(cql_type = Varint)]

pub foo: MyCustomType,
#[charybdis(cql_type = Blob)]
pub bar: OtherCustomType,

}`

GoranBrkuljan commented 3 months ago

If I understand correctly, you would like to be able to create custom type that would be mapped to CQL type. Those types would need to implement FromCqlVal and SerializeCql traits in order to work with the driver.

Can you tell me what types you need?

I think it would make more sense if we try to cover each use case in ORM, rather than having support for custom types as we already support all native CQL types & UDTs . E.g. we could add enums that would convert to TinyInt, but if we have complex ones we would usually use UDTs.