Skip to main content

TableQueryBuilder

Struct TableQueryBuilder 

Source
pub struct TableQueryBuilder { /* private fields */ }
Expand description

Query Builder khusus tabel yang sangat mudah diketik tanpa anotasi <>.

Implementations§

Source§

impl TableQueryBuilder

Source

pub fn new(tx: Transaction, table: &'static str) -> TableQueryBuilder

Source

pub fn select(self, cols: &str) -> TableQueryBuilder

Tentukan kolom yang akan diambil (default: “*”)

Source

pub fn soft_deletes(self) -> TableQueryBuilder

Aktifkan mode soft deletes pada query tabel ini

Source

pub fn with_trashed(self) -> TableQueryBuilder

Sertakan data yang telah di-soft-delete dalam query

Source

pub fn only_trashed(self) -> TableQueryBuilder

Ambil HANYA data yang telah di-soft-delete (Recycle Bin)

Source

pub fn order_by(self, column: &str, direction: &str) -> TableQueryBuilder

Urutkan hasil query

Source

pub fn latest(self) -> TableQueryBuilder

Shortcut urutkan dari yang terbaru (created_at DESC)

Source

pub fn oldest(self) -> TableQueryBuilder

Shortcut urutkan dari yang terlama (created_at ASC)

Source

pub fn limit(self, n: usize) -> TableQueryBuilder

Batasi jumlah baris hasil query

Source

pub fn offset(self, n: usize) -> TableQueryBuilder

Lewati sejumlah baris

Source

pub fn where_eq<V>(self, column: &str, value: V) -> TableQueryBuilder
where V: ToString,

Filter WHERE column = value

Source

pub fn where_ne<V>(self, column: &str, value: V) -> TableQueryBuilder
where V: ToString,

Filter WHERE column != value

Source

pub fn where_like<V>(self, column: &str, pattern: V) -> TableQueryBuilder
where V: ToString,

Filter WHERE column LIKE pattern

Source

pub fn where_null(self, column: &str) -> TableQueryBuilder

Filter WHERE column IS NULL

Source

pub fn where_not_null(self, column: &str) -> TableQueryBuilder

Filter WHERE column IS NOT NULL

Source

pub async fn get(&self) -> Result<Vec<Value>, Error>

Ambil semua baris data sebagai Vec<serde_json::Value>

Source

pub async fn first(&self) -> Result<Option<Value>, Error>

Ambil satu baris data pertama sebagai Option<serde_json::Value>

Source

pub async fn count(&self) -> Result<i64, Error>

Hitung jumlah baris data yang cocok dengan kriteria filter

Source

pub async fn decrement(&self, column: &str, amount: i64) -> Result<u64, Error>

Kurangkan nilai kolom secara atomik di database (Laravel: decrement).

Source

pub async fn increment(&self, column: &str, amount: i64) -> Result<u64, Error>

Tambahkan nilai kolom secara atomik di database (Laravel: increment).

Source

pub async fn insert<K, V>( &self, values: impl IntoIterator<Item = (K, V)>, ) -> Result<u64, Error>
where K: AsRef<str>, V: ToString,

Insert baris baru ke tabel (Laravel: insert).

Source

pub async fn update<K, V>( &self, values: impl IntoIterator<Item = (K, V)>, ) -> Result<u64, Error>
where K: AsRef<str>, V: ToString,

Update baris pada tabel berdasarkan filter WHERE yang ditentukan.

Source

pub async fn delete(&self) -> Result<u64, Error>

Hapus baris dari tabel. Jika soft_deletes aktif, set deleted_at = CURRENT_TIMESTAMP. Jika tidak aktif, lakukan penghapusan fisik permanen (DELETE FROM).

Source

pub async fn restore(&self) -> Result<u64, Error>

Pulihkan data yang terhapus sementara (Soft Delete Restore: set deleted_at = NULL).

Source

pub async fn force_delete(&self) -> Result<u64, Error>

Hapus fisik permanen dari database (Hard Delete).

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more