pub mod shared;
cfg_if! {if #[cfg(any(
feature = "mysql-sync",
feature = "postgres-sync",
feature = "sqlite-sync",
feature = "oracle-sync",
feature = "mssql-sync"
))] {
pub mod blocking;
}}
cfg_if! {if #[cfg(any(
feature = "mysql-async",
feature = "postgres-async",
feature = "sqlite-async",
feature = "oracle-async",
feature = "mssql-async"
))] {
pub mod non_blocking;
}}
use akita_core::cfg_if;
use serde::{Deserialize, Serialize};
#[derive(Debug, Clone)]
pub struct PaginationOptions {
pub page: u64,
pub size: u64,
pub order_by: Option<String>,
pub need_total: bool,
}
#[derive(Clone, Deserialize, Serialize)]
pub struct IPage<T>
where
T: Sized,
{
pub total: u64,
pub size: u64,
pub current: u64,
pub records: Vec<T>,
}
impl<T> IPage<T>
where
T: Sized,
{
pub fn new(current: u64, size: u64, total: u64, records: Vec<T>) -> Self {
Self {
total,
size,
current,
records,
}
}
pub fn offset(&self) -> u64 {
if self.current > 0 {
(self.current - 1) * self.size
} else {
0
}
}
}