Scyllax (sɪl-æks)
A SQLx and Discord inspired query system for ScyllaDB
Example
1. Model definition
Before you can write any queries, you have to define a model.
#[derive(Clone, Debug, FromRow, PartialEq, ValueList, Entity)]
pub struct PersonEntity {
#[pk]
pub id: uuid::Uuid,
pub email: String,
pub created_at: i64,
}
2. Select queries
With the [select_query] attribute, it's easy to define select queries.
#[select_query(
query = "select * from person where id = ? limit 1",
entity_type = "PersonEntity"
)]
pub struct GetPersonById {
pub id: Uuid,
}
3. Upsert queries
With the [upsert_query] attribute, it's easy to define upsert queries.
#[upsert_query(table = "person", name = UpsertPerson)]
#[derive(Clone, Debug, FromRow, PartialEq, ValueList, Entity)]
pub struct PersonEntity {
#[pk]
pub id: uuid::Uuid,
pub email: String,
pub created_at: i64,
}