Skip to content

Commit

Permalink
mention column type override in readme
Browse files Browse the repository at this point in the history
  • Loading branch information
johnny-smitherson committed Dec 27, 2024
1 parent dea1952 commit 5941cbb
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions charybdis/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -827,3 +827,29 @@ pub struct User {
So field `organization` will be ignored in all operations and
default value will be used when deserializing from other data sources.
It can be used to hold data that is not persisted in database.

## Custom Fields

Any rust type can be used directly in table or UDT definition.
User must choose a ScyllaDB backing type (such as "TinyInt" or "Text")
and implement `SerializeValue` and `DeserializeValue` traits:


```rust
#[charybdis_model(...)]
pub struct User {
id: Uuid,
#[charybdis(column_type = "Text")]
extra_data: CustomField,
}

impl<'frame, 'metadata> DeserializeValue<'frame, 'metadata> for CustomField {
...
}

impl SerializeValue for CustomField {
...
}
```

See `custom_field.rs` integration test for examples using int and text encoding.

0 comments on commit 5941cbb

Please sign in to comment.