Struct auditor::client::QueryBuilder
source · pub struct QueryBuilder {
pub query_params: QueryParameters,
}
Expand description
The QueryBuilder
is used to construct QueryParameters
using the builder pattern.
It is used to fetch records using query parameters such as start_time, stop_time etc.
§Examples
use auditor::client::{QueryBuilder, Operator, MetaQuery, ComponentQuery, SortBy};
// Create a new QueryBuilder instance.
let query_builder = QueryBuilder::new()
.with_start_time(Operator::default()) // Set start time operator.
.with_stop_time(Operator::default()) // Set stop time operator.
.with_runtime(Operator::default()) // Set runtime operator.
.with_meta_query(MetaQuery::new()) // Set meta query.
.with_component_query(ComponentQuery::new()) // Set component query.
.sort_by(SortBy::new()) // Set sort by options
.limit(1000); // Limit the number of queries
// For querying all records, just create an empty QueryBuilder instance without operators
let query_builder = QueryBuilder::new();
// Build the query string.
let query_string = query_builder.build();
println!("Generated query string: {}", query_string);
Fields§
§query_params: QueryParameters
Query parameters to be built.
Implementations§
source§impl QueryBuilder
impl QueryBuilder
sourcepub fn with_record_id(self, record_id: String) -> Self
pub fn with_record_id(self, record_id: String) -> Self
Sets the exact record to be queried from the database using record id
sourcepub fn with_start_time(self, time_operator: Operator) -> Self
pub fn with_start_time(self, time_operator: Operator) -> Self
Sets the start time in the query parameters.
sourcepub fn with_stop_time(self, time_operator: Operator) -> Self
pub fn with_stop_time(self, time_operator: Operator) -> Self
Sets the stop time in the query parameters.
sourcepub fn with_runtime(self, time_operator: Operator) -> Self
pub fn with_runtime(self, time_operator: Operator) -> Self
Sets the runtime in the query parameters.
sourcepub fn with_meta_query(self, meta: MetaQuery) -> Self
pub fn with_meta_query(self, meta: MetaQuery) -> Self
Sets the meta query in the query parameters.
sourcepub fn with_component_query(self, component: ComponentQuery) -> Self
pub fn with_component_query(self, component: ComponentQuery) -> Self
Sets the component query in the query parameters.
pub fn limit(self, number: u64) -> Self
sourcepub async fn get(
&self,
client: AuditorClient
) -> Result<Vec<Record>, ClientError>
pub async fn get( &self, client: AuditorClient ) -> Result<Vec<Record>, ClientError>
Trait Implementations§
source§impl Clone for QueryBuilder
impl Clone for QueryBuilder
source§fn clone(&self) -> QueryBuilder
fn clone(&self) -> QueryBuilder
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Debug for QueryBuilder
impl Debug for QueryBuilder
Auto Trait Implementations§
impl Freeze for QueryBuilder
impl RefUnwindSafe for QueryBuilder
impl Send for QueryBuilder
impl Sync for QueryBuilder
impl Unpin for QueryBuilder
impl UnwindSafe for QueryBuilder
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
source§impl<T> FutureExt for T
impl<T> FutureExt for T
source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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