pub struct SelectSpec {
pub model_name: String,
pub fields: FieldSelection,
pub relations: HashMap<String, SelectSpec>,
}Expand description
Specification for which fields to select from a model.
Fields§
§model_name: StringModel name this selection is for.
fields: FieldSelectionFields to include (empty means all).
relations: HashMap<String, SelectSpec>Relation selections.
Implementations§
Source§impl SelectSpec
impl SelectSpec
Sourcepub fn only(
model_name: impl Into<String>,
fields: impl IntoIterator<Item = impl Into<String>>,
) -> Self
pub fn only( model_name: impl Into<String>, fields: impl IntoIterator<Item = impl Into<String>>, ) -> Self
Select only specific fields.
Sourcepub fn except(
model_name: impl Into<String>,
fields: impl IntoIterator<Item = impl Into<String>>,
) -> Self
pub fn except( model_name: impl Into<String>, fields: impl IntoIterator<Item = impl Into<String>>, ) -> Self
Exclude specific fields.
Sourcepub fn fields(self, names: impl IntoIterator<Item = impl Into<String>>) -> Self
pub fn fields(self, names: impl IntoIterator<Item = impl Into<String>>) -> Self
Add multiple fields to the selection.
Sourcepub fn relation(self, name: impl Into<String>, select: SelectSpec) -> Self
pub fn relation(self, name: impl Into<String>, select: SelectSpec) -> Self
Include a relation with its selection.
Sourcepub fn is_field_selected(&self, field: &str) -> bool
pub fn is_field_selected(&self, field: &str) -> bool
Check if a field is selected.
Sourcepub fn selected_fields(&self) -> Option<&HashSet<String>>
pub fn selected_fields(&self) -> Option<&HashSet<String>>
Get the list of selected fields (if explicit).
Sourcepub fn excluded_fields(&self) -> Option<&HashSet<String>>
pub fn excluded_fields(&self) -> Option<&HashSet<String>>
Get the list of excluded fields (if explicit).
Trait Implementations§
Source§impl Clone for SelectSpec
impl Clone for SelectSpec
Auto Trait Implementations§
impl Forget for SelectSpec
impl Freeze for SelectSpec
impl Move for SelectSpec
impl RefUnwindSafe for SelectSpec
impl Send for SelectSpec
impl Sync for SelectSpec
impl Unpin for SelectSpec
impl UnsafeUnpin for SelectSpec
impl UnwindSafe for SelectSpec
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