use arangors_lite::{ClientError, Database};
pub use {
collection_schema::CollectionSchema, database_schema::DatabaseSchema,
graph_schema::GraphSchema, index_schema::IndexSchema,
};
mod collection_schema;
mod database_schema;
mod graph_schema;
mod index_schema;
pub const SCHEMA_DEFAULT_PATH: &str = "./src/config/db";
pub const SCHEMA_DEFAULT_FILE_NAME: &str = "schema.yaml";
#[maybe_async::maybe_async]
pub trait SchemaDatabaseOperation {
type PoolType;
fn handle_error<T>(result: Result<T, ClientError>, silent: bool) -> Result<(), ClientError> {
match result {
Err(error) => {
if silent {
log::debug!("Ignored error: {}", error);
return Ok(());
}
Err(error)
}
Ok(_val) => Ok(()),
}
}
fn handle_pool_result(
result: Result<Self::PoolType, ClientError>,
silent: bool,
) -> Result<Option<Self::PoolType>, ClientError> {
let res = match result {
Err(error) => {
Self::handle_error(Err(error) as Result<Self::PoolType, ClientError>, silent)?;
None
}
Ok(val) => Some(val),
};
Ok(res)
}
async fn apply_to_database(
&self,
database: &Database,
silent: bool,
) -> Result<Option<Self::PoolType>, ClientError>;
async fn drop(&self, database: &Database) -> Result<(), ClientError>;
async fn get(&self, database: &Database) -> Result<Self::PoolType, ClientError>;
}