Struct query_structure::prelude::FieldSelection
source · pub struct FieldSelection { /* private fields */ }
Expand description
A selection of fields from a model.
Implementations§
source§impl FieldSelection
impl FieldSelection
pub fn new(selections: Vec<SelectedField>) -> Self
pub fn into_inner(self) -> Vec<SelectedField>
sourcepub fn is_superset_of(&self, other: &Self) -> bool
pub fn is_superset_of(&self, other: &Self) -> bool
Returns true
if self contains (at least) all fields specified in other
. false
otherwise.
Recurses into composite selections and ensures that composite selections are supersets as well.
pub fn selections(&self) -> impl Iterator<Item = &SelectedField> + '_
pub fn virtuals(&self) -> impl Iterator<Item = &VirtualSelection>
pub fn virtuals_owned(&self) -> Vec<VirtualSelection>
pub fn without_relations(&self) -> Self
pub fn into_virtuals_last(self) -> Self
sourcepub fn prisma_names(&self) -> impl Iterator<Item = String> + '_
pub fn prisma_names(&self) -> impl Iterator<Item = String> + '_
Returns all Prisma (e.g. schema model field) names of contained fields. Does not recurse into composite selections and only iterates top level fields.
sourcepub fn db_names(&self) -> impl Iterator<Item = String> + '_
pub fn db_names(&self) -> impl Iterator<Item = String> + '_
Returns all database (e.g. column or document field) names of contained fields. Does not recurse into composite selections and only iterates top level fields. Returns db aliases for virtual fields grouped into objects in the query separately, representing results of queries that do not load relations using JOINs.
sourcepub fn db_names_grouping_virtuals(&self) -> impl Iterator<Item = String> + '_
pub fn db_names_grouping_virtuals(&self) -> impl Iterator<Item = String> + '_
Returns all database (e.g. column or document field) names of contained fields. Does not
recurse into composite selections and only iterates top level fields. Also does not recurse
into the grouped containers for virtual fields, like _count
. The names returned by this
method correspond to the results of queries that use JSON objects to represent joined
relations and relation aggregations.
sourcepub fn contains(&self, name: &str) -> bool
pub fn contains(&self, name: &str) -> bool
Checked if a field of prisma name name
is present in this FieldSelection
.
pub fn get(&self, name: &str) -> Option<&SelectedField>
pub fn as_fields(&self) -> Vec<Field>
sourcepub fn as_scalar_fields(&self) -> Option<Vec<ScalarFieldRef>>
pub fn as_scalar_fields(&self) -> Option<Vec<ScalarFieldRef>>
Checks if self
only contains scalar field selections and if so, returns them all in a list.
If any other selection is contained, returns None
.
sourcepub fn assimilate(&self, values: SelectionResult) -> Result<SelectionResult>
pub fn assimilate(&self, values: SelectionResult) -> Result<SelectionResult>
Inserts this FieldSelection
s selections into the given SelectionResult
.
Assumes caller knows that the exchange can be done, but still errors if lengths mismatch.
Additionally performs a type coercion based on the source and destination field types.
Resistance is futile.
sourcepub fn matches(&self, result: &SelectionResult) -> bool
pub fn matches(&self, result: &SelectionResult) -> bool
Checks if a given SelectionResult
belongs to this FieldSelection
.
sourcepub fn union(selections: Vec<Self>) -> Self
pub fn union(selections: Vec<Self>) -> Self
Merges all given FieldSelection
a set union of all.
Each selection is contained exactly once, with the first
occurrence of the first field in order from left to right
is retained.
/!\ Important assumption: All selections are on the same model.
sourcepub fn merge(self, other: FieldSelection) -> FieldSelection
pub fn merge(self, other: FieldSelection) -> FieldSelection
Consumes both FieldSelection
s to create a new one that contains a union
of both. Each selection is contained exactly once, with the first
occurrence of the first field in order from left (self
) to right (other
)
is retained. Assumes that both selections reason over the same model.
pub fn merge_in_place(&mut self, other: FieldSelection)
sourcepub fn type_identifiers_with_arities(&self) -> Vec<(TypeIdentifier, FieldArity)>
pub fn type_identifiers_with_arities(&self) -> Vec<(TypeIdentifier, FieldArity)>
Returns type identifiers and arities, treating all virtual fields as separate fields.
sourcepub fn type_identifiers_with_arities_grouping_virtuals(
&self
) -> Vec<(TypeIdentifier, FieldArity)>
pub fn type_identifiers_with_arities_grouping_virtuals( &self ) -> Vec<(TypeIdentifier, FieldArity)>
Returns type identifiers and arities, grouping the virtual fields so that the type identifier and arity is returned for the whole object containing multiple virtual fields and not each of those fields separately. This represents the selection in joined queries that use JSON objects for relations and relation aggregations.
pub fn relations(&self) -> impl Iterator<Item = &RelationSelection>
pub fn into_projection(self) -> ModelProjection
pub fn has_virtual_fields(&self) -> bool
Trait Implementations§
source§impl Clone for FieldSelection
impl Clone for FieldSelection
source§fn clone(&self) -> FieldSelection
fn clone(&self) -> FieldSelection
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for FieldSelection
impl Debug for FieldSelection
source§impl Default for FieldSelection
impl Default for FieldSelection
source§fn default() -> FieldSelection
fn default() -> FieldSelection
source§impl Display for FieldSelection
impl Display for FieldSelection
source§impl From<&FieldSelection> for ModelProjection
impl From<&FieldSelection> for ModelProjection
[Composites] todo: Temporary converter.
source§fn from(fs: &FieldSelection) -> Self
fn from(fs: &FieldSelection) -> Self
source§impl From<&FieldSelection> for SelectionResult
impl From<&FieldSelection> for SelectionResult
source§fn from(fs: &FieldSelection) -> Self
fn from(fs: &FieldSelection) -> Self
source§impl From<&SelectionResult> for FieldSelection
impl From<&SelectionResult> for FieldSelection
source§fn from(p: &SelectionResult) -> Self
fn from(p: &SelectionResult) -> Self
source§impl From<FieldSelection> for ModelProjection
impl From<FieldSelection> for ModelProjection
source§fn from(fs: FieldSelection) -> Self
fn from(fs: FieldSelection) -> Self
source§impl From<Vec<Zipper<ScalarFieldId>>> for FieldSelection
impl From<Vec<Zipper<ScalarFieldId>>> for FieldSelection
source§fn from(fields: Vec<ScalarFieldRef>) -> Self
fn from(fields: Vec<ScalarFieldRef>) -> Self
source§impl Hash for FieldSelection
impl Hash for FieldSelection
source§impl IntoIterator for FieldSelection
impl IntoIterator for FieldSelection
§type Item = SelectedField
type Item = SelectedField
§type IntoIter = IntoIter<<FieldSelection as IntoIterator>::Item>
type IntoIter = IntoIter<<FieldSelection as IntoIterator>::Item>
source§impl PartialEq for FieldSelection
impl PartialEq for FieldSelection
source§fn eq(&self, other: &FieldSelection) -> bool
fn eq(&self, other: &FieldSelection) -> bool
self
and other
values to be equal, and is used
by ==
.source§impl ScalarCompare for FieldSelection
impl ScalarCompare for FieldSelection
source§fn is_in<T>(&self, values: T) -> Filterwhere
T: Into<ConditionListValue>,
fn is_in<T>(&self, values: T) -> Filterwhere T: Into<ConditionListValue>,
Field is in a given value
source§fn not_in<T>(&self, values: T) -> Filterwhere
T: Into<ConditionListValue>,
fn not_in<T>(&self, values: T) -> Filterwhere T: Into<ConditionListValue>,
Field is not in a given value
source§fn equals<T>(&self, val: T) -> Filterwhere
T: Into<ConditionValue>,
fn equals<T>(&self, val: T) -> Filterwhere T: Into<ConditionValue>,
Field equals the given value.
source§fn not_equals<T>(&self, val: T) -> Filterwhere
T: Into<ConditionValue>,
fn not_equals<T>(&self, val: T) -> Filterwhere T: Into<ConditionValue>,
Field does not equal the given value.
source§fn contains<T>(&self, val: T) -> Filterwhere
T: Into<ConditionValue>,
fn contains<T>(&self, val: T) -> Filterwhere T: Into<ConditionValue>,
Field contains the given value.
source§fn not_contains<T>(&self, val: T) -> Filterwhere
T: Into<ConditionValue>,
fn not_contains<T>(&self, val: T) -> Filterwhere T: Into<ConditionValue>,
Field does not contain the given value.
source§fn starts_with<T>(&self, val: T) -> Filterwhere
T: Into<ConditionValue>,
fn starts_with<T>(&self, val: T) -> Filterwhere T: Into<ConditionValue>,
Field starts with the given value.
source§fn not_starts_with<T>(&self, val: T) -> Filterwhere
T: Into<ConditionValue>,
fn not_starts_with<T>(&self, val: T) -> Filterwhere T: Into<ConditionValue>,
Field does not start with the given value.
source§fn ends_with<T>(&self, val: T) -> Filterwhere
T: Into<ConditionValue>,
fn ends_with<T>(&self, val: T) -> Filterwhere T: Into<ConditionValue>,
Field ends with the given value.
source§fn not_ends_with<T>(&self, val: T) -> Filterwhere
T: Into<ConditionValue>,
fn not_ends_with<T>(&self, val: T) -> Filterwhere T: Into<ConditionValue>,
Field does not end with the given value.
source§fn less_than<T>(&self, val: T) -> Filterwhere
T: Into<ConditionValue>,
fn less_than<T>(&self, val: T) -> Filterwhere T: Into<ConditionValue>,
Field is less than the given value.
source§fn less_than_or_equals<T>(&self, val: T) -> Filterwhere
T: Into<ConditionValue>,
fn less_than_or_equals<T>(&self, val: T) -> Filterwhere T: Into<ConditionValue>,
Field is less than or equals the given value.
source§fn greater_than<T>(&self, val: T) -> Filterwhere
T: Into<ConditionValue>,
fn greater_than<T>(&self, val: T) -> Filterwhere T: Into<ConditionValue>,
Field is greater than the given value.
source§fn greater_than_or_equals<T>(&self, val: T) -> Filterwhere
T: Into<ConditionValue>,
fn greater_than_or_equals<T>(&self, val: T) -> Filterwhere T: Into<ConditionValue>,
Field is greater than or equals the given value.
fn search<T>(&self, val: T) -> Filterwhere T: Into<ConditionValue>,
fn not_search<T>(&self, val: T) -> Filterwhere T: Into<ConditionValue>,
fn is_set(&self, val: bool) -> Filter
impl Eq for FieldSelection
impl StructuralEq for FieldSelection
impl StructuralPartialEq for FieldSelection
Auto Trait Implementations§
impl !RefUnwindSafe for FieldSelection
impl Send for FieldSelection
impl Sync for FieldSelection
impl Unpin for FieldSelection
impl !UnwindSafe for FieldSelection
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
source§impl<T> CallHasher for Twhere
T: Hash + ?Sized,
impl<T> CallHasher for Twhere T: Hash + ?Sized,
source§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.source§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.