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>
impl<'db> ScalarFieldAttributeWalker<'db>
sourcepub fn length(self) -> Option<u32>
pub fn length(self) -> Option<u32>
The length argument on the field.
@@index(name(length: 10))
^^
sourcepub fn operator_class(self) -> Option<OperatorClassWalker<'db>>
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)
^^^^^^^
sourcepub fn as_index_field(self) -> IndexFieldWalker<'db>
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])
}
sourcepub fn as_path_to_indexed_field(self) -> Vec<(&'db str, Option<&'db str>)>
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.
sourcepub fn as_mapped_path_to_indexed_field(
self
) -> Vec<(&'db str, Option<&'db str>)>
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.
sourcepub fn sort_order(self) -> Option<SortOrder>
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>
impl<'db> Clone for ScalarFieldAttributeWalker<'db>
source§fn clone(&self) -> ScalarFieldAttributeWalker<'db>
fn clone(&self) -> ScalarFieldAttributeWalker<'db>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more