Struct datamodel_renderer::datamodel::View
source · pub struct View<'a> { /* private fields */ }
Expand description
Defines a model block.
Implementations§
source§impl<'a> View<'a>
impl<'a> View<'a>
sourcepub fn new(name: impl Into<Cow<'a, str>>) -> Self
pub fn new(name: impl Into<Cow<'a, str>>) -> Self
Create a new view declaration.
ⓘ
view User {
// ^^^^ name
}
sourcepub fn documentation(&mut self, documentation: impl Into<Cow<'a, str>>)
pub fn documentation(&mut self, documentation: impl Into<Cow<'a, str>>)
Documentation of the view. If called repeatedly, adds the new docs to the end with a newline.
ⓘ
/// This is the documentation.
view Foo {
....
}
sourcepub fn id(&mut self, id: IdDefinition<'a>)
pub fn id(&mut self, id: IdDefinition<'a>)
Add a view-level id definition.
ⓘ
view Foo {
@@id([field1, field2(sort: Desc)])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this
}
sourcepub fn map(&mut self, map: impl Into<Cow<'a, str>>)
pub fn map(&mut self, map: impl Into<Cow<'a, str>>)
Add a view-level mapping.
ⓘ
view Foo {
@@map("1Foo")
^^^^^^^^^^^^^ this
}
sourcepub fn schema(&mut self, schema: impl Into<Cow<'a, str>>)
pub fn schema(&mut self, schema: impl Into<Cow<'a, str>>)
The schema attribute of the view block
ⓘ
view Foo {
@@schema("public")
^^^^^^^^^^^^^^^^^^ this
}
sourcepub fn push_field(&mut self, field: Field<'a>)
pub fn push_field(&mut self, field: Field<'a>)
Push a new field to the view.
ⓘ
view Foo {
id Int @id
^^^^^^^^^^ this
}
sourcepub fn push_index(&mut self, index: IndexDefinition<'a>)
pub fn push_index(&mut self, index: IndexDefinition<'a>)
Push a new index to the view.
ⓘ
view Foo {
@@index([field1, field2])
^^^^^^^^^^^^^^^^^^^^^^^^^ this
}
Trait Implementations§
Auto Trait Implementations§
impl<'a> RefUnwindSafe for View<'a>
impl<'a> Send for View<'a>
impl<'a> Sync for View<'a>
impl<'a> Unpin for View<'a>
impl<'a> UnwindSafe for View<'a>
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