pub trait Entity<'a>: Sized + PartialEq + Eq + Debug {
    const TYPE_ID: i64;
    const JOIN_METADATA: Option<[Option<JoinMetadata<'a>>; 10]>;

    // Required methods
    fn from_row(vec: Vec<FtColumn>) -> Self;
    fn to_row(&self) -> Vec<FtColumn>;

    // Provided methods
    fn type_id(&self) -> i64 { ... }
    fn save_many_to_many(&self) { ... }
    fn load(id: UID) -> Option<Self> { ... }
    fn load_unsafe(id: UID) -> Option<Self> { ... }
    fn find(filter: impl Into<SingleFilter<Self>>) -> Option<Self> { ... }
    fn find_many(filter: impl Into<ManyFilter<Self>>) -> Vec<Self> { ... }
    fn save(&self) { ... }
    fn save_unsafe(&self) { ... }
}
Expand description

Trait for a type entity.

Any entity type that will be processed through a WASM indexer is required to implement this trait.

Required Associated Constants§

source

const TYPE_ID: i64

Unique identifier for a type.

source

const JOIN_METADATA: Option<[Option<JoinMetadata<'a>>; 10]>

Necessary metadata for saving an entity’s list type fields.

Required Methods§

source

fn from_row(vec: Vec<FtColumn>) -> Self

Convert database row representation into an instance of an entity.

source

fn to_row(&self) -> Vec<FtColumn>

Convert an instance of an entity into a row representation for use in a database.

Provided Methods§

source

fn type_id(&self) -> i64

Returns an entity’s internal type ID.

source

fn save_many_to_many(&self)

Saves a record that contains a list of multiple elements.

source

fn load(id: UID) -> Option<Self>

Loads a record given a UID.

source

fn load_unsafe(id: UID) -> Option<Self>

Loads a record through the FFI with the WASM runtime and checks for errors.

source

fn find(filter: impl Into<SingleFilter<Self>>) -> Option<Self>

Finds the first entity that satisfies the given constraints.

source

fn find_many(filter: impl Into<ManyFilter<Self>>) -> Vec<Self>

Finds the entities that satisfy the given constraints.

source

fn save(&self)

Saves a record.

source

fn save_unsafe(&self)

Saves a record through the FFI with the WASM runtime and checks for errors.

Object Safety§

This trait is not object safe.

Implementors§