pub struct Pipeline { /* private fields */ }Expand description
A query pipeline for executing multiple queries efficiently.
Pipelines combine multiple queries and execute them with minimal round-trips to the database. This is especially useful for:
- Fetching a parent record and its relations
- Performing multiple inserts in sequence
- Complex transactions with multiple operations
§Example
ⓘ
use prax_query::batch::Pipeline;
let pipeline = Pipeline::new()
.query("SELECT * FROM users WHERE id = $1", vec![id.into()])
.query("SELECT * FROM posts WHERE author_id = $1", vec![id.into()])
.build();
let results = engine.execute_pipeline(pipeline).await?;Implementations§
Source§impl Pipeline
impl Pipeline
Sourcepub fn with_capacity(capacity: usize) -> Self
pub fn with_capacity(capacity: usize) -> Self
Create a pipeline with pre-allocated capacity.
Sourcepub fn push(&mut self, sql: impl Into<String>, params: Vec<FilterValue>)
pub fn push(&mut self, sql: impl Into<String>, params: Vec<FilterValue>)
Add a query to the pipeline.
Sourcepub fn push_execute(&mut self, sql: impl Into<String>, params: Vec<FilterValue>)
pub fn push_execute(&mut self, sql: impl Into<String>, params: Vec<FilterValue>)
Add an execute-only query (no result rows expected).
Sourcepub fn queries(&self) -> &[PipelineQuery]
pub fn queries(&self) -> &[PipelineQuery]
Get the queries.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Pipeline
impl RefUnwindSafe for Pipeline
impl Send for Pipeline
impl Sync for Pipeline
impl Unpin for Pipeline
impl UnwindSafe for Pipeline
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