Trait ormlite_core::model::Model
source · pub trait Model<DB>{
// Required methods
fn insert<'a, A>(self, conn: A) -> Insertion<'a, A, Self, DB>
where A: 'a + Send + Acquire<'a, Database = DB>,
Self: Send;
fn update_all_fields<'e, E>(self, db: E) -> BoxFuture<'e, Result<Self>>
where E: 'e + Send + Executor<'e, Database = DB>;
fn delete<'e, E>(self, db: E) -> BoxFuture<'e, Result<()>>
where E: 'e + Executor<'e, Database = DB>;
fn fetch_one<'e, 'a, Arg, E>(id: Arg, db: E) -> BoxFuture<'e, Result<Self>>
where E: 'e + Executor<'e, Database = DB>,
Arg: 'a + Send + Encode<'a, DB> + Type<DB>,
'a: 'e;
fn query(
query: &str
) -> QueryAs<'_, DB, Self, <DB as HasArguments<'_>>::Arguments>;
fn select<'args>() -> SelectQueryBuilder<'args, DB, Self>;
}Expand description
The core trait. a struct that implements Model can also implement HasModelBuilder, (and is required to implement Insertable)
Required Methods§
sourcefn insert<'a, A>(self, conn: A) -> Insertion<'a, A, Self, DB>
fn insert<'a, A>(self, conn: A) -> Insertion<'a, A, Self, DB>
Insert the model into the database.
sourcefn update_all_fields<'e, E>(self, db: E) -> BoxFuture<'e, Result<Self>>where
E: 'e + Send + Executor<'e, Database = DB>,
fn update_all_fields<'e, E>(self, db: E) -> BoxFuture<'e, Result<Self>>where
E: 'e + Send + Executor<'e, Database = DB>,
Model objects can’t track what fields are updated, so this method will update all fields.
If you want to update only some fields, use update_partial instead.
fn delete<'e, E>(self, db: E) -> BoxFuture<'e, Result<()>>where
E: 'e + Executor<'e, Database = DB>,
sourcefn fetch_one<'e, 'a, Arg, E>(id: Arg, db: E) -> BoxFuture<'e, Result<Self>>where
E: 'e + Executor<'e, Database = DB>,
Arg: 'a + Send + Encode<'a, DB> + Type<DB>,
'a: 'e,
fn fetch_one<'e, 'a, Arg, E>(id: Arg, db: E) -> BoxFuture<'e, Result<Self>>where
E: 'e + Executor<'e, Database = DB>,
Arg: 'a + Send + Encode<'a, DB> + Type<DB>,
'a: 'e,
Get by primary key.
sourcefn query(
query: &str
) -> QueryAs<'_, DB, Self, <DB as HasArguments<'_>>::Arguments>
fn query( query: &str ) -> QueryAs<'_, DB, Self, <DB as HasArguments<'_>>::Arguments>
If query building isn’t meeting your needs, use this method to query the table using raw SQL.
sourcefn select<'args>() -> SelectQueryBuilder<'args, DB, Self>
fn select<'args>() -> SelectQueryBuilder<'args, DB, Self>
Create a SelectQueryBuilder to build a query.
Object Safety§
This trait is not object safe.