pub struct ScalarFieldAttributeWalker<'db> { /* private fields */ }
Expand description

A scalar field as referenced in a key specification (id, index or unique).

Implementations§

source§

impl<'db> ScalarFieldAttributeWalker<'db>

source

pub fn length(self) -> Option<u32>

The length argument on the field.

@@index(name(length: 10))
                     ^^
source

pub fn operator_class(self) -> Option<OperatorClassWalker<'db>>

A custom operator class to control the operators catched by the index.

@@index([name(ops: InetOps)], type: Gist)
                   ^^^^^^^
source

pub fn as_index_field(self) -> IndexFieldWalker<'db>

The underlying field.

// either this
model Test {
  id          Int @id
  name        String
  ^^^^^^^^^^^^^^^^^^
  kind        Int

  @@index([name])
}

// or this
type A {
  field String
  ^^^^^^^^^^^^
}

model Test {
  id Int @id
  a  A

  @@index([a.field])
}
source

pub fn as_path_to_indexed_field(self) -> Vec<(&'db str, Option<&'db str>)>

Gives the full path from the current model to the field included in the index. For example, if the field is through two composite types:

type A {
  field Int
}

type B {
  a A
}

model C {
  id Int @id
  b  B

  @@index([b.a.field])
}

The method would return a vector from model to the final field:

vec![("b", None), ("a", Some("B")), ("field", Some("A"))];

The first part of the tuple is the name of the field, the second part is the name of the composite type.

This method prefers the prisma side naming, and should not be used when writing to the database.

source

pub fn as_mapped_path_to_indexed_field( self ) -> Vec<(&'db str, Option<&'db str>)>

Similar to the method as_path_to_indexed_field, but prefers the mapped names and is to be used when defining indices in the database.

source

pub fn sort_order(self) -> Option<SortOrder>

The sort order (asc or desc) on the field.

@@index(name(sort: Desc))
                   ^^^^

Trait Implementations§

source§

impl<'db> Clone for ScalarFieldAttributeWalker<'db>

source§

fn clone(&self) -> ScalarFieldAttributeWalker<'db>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<'db> Copy for ScalarFieldAttributeWalker<'db>

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

source§

fn vzip(self) -> V