pub struct TableRef { /* private fields */ }Expand description
Immutable query builder for a EdgeBase table.
ⓘ
let result = client.table("posts")
.where_("status", "==", "published")
.or_(|q| q.where_("status", "==", "draft"))
.order_by("createdAt", "desc")
.limit(20)
.get_list()
.await?;Implementations§
Source§impl TableRef
impl TableRef
pub fn new(http: Arc<HttpClient>, name: &str) -> Self
Sourcepub fn with_db(
http: Arc<HttpClient>,
name: &str,
namespace: &str,
instance_id: Option<&str>,
) -> Self
pub fn with_db( http: Arc<HttpClient>, name: &str, namespace: &str, instance_id: Option<&str>, ) -> Self
Create a TableRef for a specific DB namespace + optional instance ID.
pub fn where_<V: Serialize>(self, field: &str, op: &str, value: V) -> Self
pub fn or_(self, builder_fn: impl FnOnce(OrBuilder) -> OrBuilder) -> Self
pub fn order_by(self, field: &str, direction: &str) -> Self
pub fn limit(self, n: u32) -> Self
pub fn offset(self, n: u32) -> Self
pub fn page(self, n: u32) -> Self
pub fn search(self, q: &str) -> Self
pub fn after(self, cursor: &str) -> Self
pub fn before(self, cursor: &str) -> Self
Sourcepub async fn get_list(&self) -> Result<Value, Error>
pub async fn get_list(&self) -> Result<Value, Error>
List documents matching current filters/sorts.
Sourcepub async fn get_first(&self) -> Result<Value, Error>
pub async fn get_first(&self) -> Result<Value, Error>
Get the first record matching the current query conditions.
Returns Ok(Value::Null) if no records match.
Sourcepub async fn sql(
&self,
query: &str,
params: &[Value],
) -> Result<Vec<Value>, Error>
pub async fn sql( &self, query: &str, params: &[Value], ) -> Result<Vec<Value>, Error>
Execute admin SQL scoped to this table’s database namespace.
Sourcepub async fn update(&self, id: &str, data: &Value) -> Result<Value, Error>
pub async fn update(&self, id: &str, data: &Value) -> Result<Value, Error>
Update a document by ID.
Sourcepub async fn upsert(
&self,
record: &Value,
conflict_target: Option<&str>,
) -> Result<Value, Error>
pub async fn upsert( &self, record: &Value, conflict_target: Option<&str>, ) -> Result<Value, Error>
Create or update a document.
Sourcepub async fn insert_many(&self, records: Vec<Value>) -> Result<Value, Error>
pub async fn insert_many(&self, records: Vec<Value>) -> Result<Value, Error>
Create multiple documents in server-side batches.
Sourcepub async fn upsert_many(
&self,
records: Vec<Value>,
conflict_target: Option<&str>,
) -> Result<Value, Error>
pub async fn upsert_many( &self, records: Vec<Value>, conflict_target: Option<&str>, ) -> Result<Value, Error>
Upsert multiple documents in server-side batches.
Sourcepub async fn update_many(&self, update: &Value) -> Result<Value, Error>
pub async fn update_many(&self, update: &Value) -> Result<Value, Error>
Update all documents matching current filters.
Sourcepub async fn delete_many(&self) -> Result<Value, Error>
pub async fn delete_many(&self) -> Result<Value, Error>
Delete all documents matching current filters.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for TableRef
impl !RefUnwindSafe for TableRef
impl Send for TableRef
impl Sync for TableRef
impl Unpin for TableRef
impl UnsafeUnpin for TableRef
impl !UnwindSafe for TableRef
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more