pub struct EntitySchemaBuilder { /* private fields */ }Expand description
Fluent builder for EntitySchema.
§Example
use chainindex_core::entity::{EntitySchemaBuilder, FieldType};
let schema = EntitySchemaBuilder::new("swap")
.primary_key("id")
.field("pair", FieldType::String, true)
.field("amount_in", FieldType::Uint64, false)
.field("amount_out", FieldType::Uint64, false)
.nullable_field("memo", FieldType::String, false)
.build();Implementations§
Source§impl EntitySchemaBuilder
impl EntitySchemaBuilder
Sourcepub fn new(name: impl Into<String>) -> Self
pub fn new(name: impl Into<String>) -> Self
Create a new builder for an entity with the given name.
Sourcepub fn primary_key(self, pk: impl Into<String>) -> Self
pub fn primary_key(self, pk: impl Into<String>) -> Self
Set the primary key field name (default: "id").
Sourcepub fn field(
self,
name: impl Into<String>,
field_type: FieldType,
indexed: bool,
) -> Self
pub fn field( self, name: impl Into<String>, field_type: FieldType, indexed: bool, ) -> Self
Add a required (non-nullable) field.
Sourcepub fn nullable_field(
self,
name: impl Into<String>,
field_type: FieldType,
indexed: bool,
) -> Self
pub fn nullable_field( self, name: impl Into<String>, field_type: FieldType, indexed: bool, ) -> Self
Add a nullable field.
Sourcepub fn build(self) -> EntitySchema
pub fn build(self) -> EntitySchema
Build the EntitySchema.
Auto Trait Implementations§
impl Freeze for EntitySchemaBuilder
impl RefUnwindSafe for EntitySchemaBuilder
impl Send for EntitySchemaBuilder
impl Sync for EntitySchemaBuilder
impl Unpin for EntitySchemaBuilder
impl UnsafeUnpin for EntitySchemaBuilder
impl UnwindSafe for EntitySchemaBuilder
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