pub use error::BuildUpsertQueryError;
pub use scylla::{
prepared_statement::PreparedStatement, transport::errors::QueryError, QueryResult,
};
pub use crate::{error::ScyllaxError, executor::Executor};
pub use async_trait::async_trait;
pub use scylla::{frame::value::ValueList as ImplValueList, FromRow};
pub use scyllax_macros::*;
pub mod error;
pub mod executor;
pub mod maybe_unset;
pub mod prelude;
pub mod rows;
pub mod util;
pub trait EntityExt<T: ImplValueList + FromRow> {
fn keys() -> Vec<String>;
fn pks() -> Vec<String>;
}
#[async_trait]
pub trait SelectQuery<
T: EntityExt<T> + ImplValueList + FromRow,
R: Clone + std::fmt::Debug + Send + Sync,
>
{
fn query() -> String;
async fn prepare(db: &Executor) -> Result<PreparedStatement, QueryError>;
async fn execute(self, db: &Executor) -> Result<QueryResult, QueryError>;
async fn parse_response(res: QueryResult) -> Result<R, ScyllaxError>;
}
#[async_trait]
pub trait UpsertQuery<T: EntityExt<T> + ImplValueList + FromRow> {
fn query(
&self,
) -> Result<(String, scylla::frame::value::SerializedValues), BuildUpsertQueryError>;
async fn execute(self, db: &Executor) -> Result<QueryResult, ScyllaxError>;
}
#[async_trait]
pub trait DeleteQuery<T: EntityExt<T> + ImplValueList + FromRow> {
fn query() -> String;
async fn prepare(db: &Executor) -> Result<PreparedStatement, QueryError>;
async fn execute(self, db: &Executor) -> Result<QueryResult, QueryError>;
}