Trait axum_restful::views::operates::ModelViewExt
source · pub trait ModelViewExt<T>where
T: ActiveModelTrait + ActiveModelBehavior + Send + 'static + Sync,
for<'de> <T::Entity as EntityTrait>::Model: IntoActiveModel<T> + Serialize + Sync + Deserialize<'de>,{
Show 21 methods
// Required method
fn order_by_desc() -> <T::Entity as EntityTrait>::Column;
// Provided methods
fn modle_name() -> String { ... }
fn get_db_connection<'async_trait>(
) -> Pin<Box<dyn Future<Output = &'static DatabaseConnection> + Send + 'async_trait>> { ... }
fn http_create<'async_trait>(
__arg0: Json<<T::Entity as EntityTrait>::Model>
) -> Pin<Box<dyn Future<Output = Result<StatusCode>> + Send + 'async_trait>>
where Self: Send + 'async_trait { ... }
fn set_model_primary_key(active_model: &mut T, value: u64) { ... }
fn http_update<'async_trait>(
__arg0: Path<u64>,
__arg1: Json<<T::Entity as EntityTrait>::Model>
) -> Pin<Box<dyn Future<Output = Result<StatusCode>> + Send + 'async_trait>>
where Self: Send + 'async_trait { ... }
fn check_instance_exists<'async_trait>(
pk: u64
) -> Pin<Box<dyn Future<Output = Result<<T::Entity as EntityTrait>::Model>> + Send + 'async_trait>>
where Self: Send + 'async_trait { ... }
fn http_list<'async_trait>(
__arg0: Query<Value>
) -> Pin<Box<dyn Future<Output = Result<Json<Value>>> + Send + 'async_trait>>
where Self: Send + 'async_trait { ... }
fn http_retrieve<'async_trait>(
__arg0: Path<u64>
) -> Pin<Box<dyn Future<Output = Result<Response>> + Send + 'async_trait>>
where Self: Send + 'async_trait { ... }
fn http_delete<'async_trait>(
__arg0: Path<u64>
) -> Pin<Box<dyn Future<Output = Result<StatusCode>> + Send + 'async_trait>>
where Self: Send + 'async_trait { ... }
fn http_delete_all<'async_trait>(
) -> Pin<Box<dyn Future<Output = Result<StatusCode>> + Send + 'async_trait>>
where Self: Send + 'async_trait { ... }
fn exchange_primary_key(
id: u64
) -> <<T::Entity as EntityTrait>::PrimaryKey as PrimaryKeyTrait>::ValueType { ... }
fn get_page_size(query: &Value) -> u64 { ... }
fn inner_get_page_size(query: &Value) -> Result<u64> { ... }
fn page_size_param() -> &'static str { ... }
fn default_page_size() -> u64 { ... }
fn get_page_num(query: &Value) -> u64 { ... }
fn inner_get_page_num(query: &Value) -> Result<u64> { ... }
fn page_num_param() -> &'static str { ... }
fn default_page_num() -> u64 { ... }
fn http_router(nest_prefix: &'static str) -> Router
where Self: Send + 'static { ... }
}
Required Methods§
sourcefn order_by_desc() -> <T::Entity as EntityTrait>::Column
fn order_by_desc() -> <T::Entity as EntityTrait>::Column
TODO: patch need value trans into active model value PATCH a json body to /api/:id return http 200 StatusCode::OK if matched, or return 404 if not matched a query
Provided Methods§
fn modle_name() -> String
sourcefn get_db_connection<'async_trait>(
) -> Pin<Box<dyn Future<Output = &'static DatabaseConnection> + Send + 'async_trait>>
fn get_db_connection<'async_trait>( ) -> Pin<Box<dyn Future<Output = &'static DatabaseConnection> + Send + 'async_trait>>
get default db connection with default config you can change this when impl ModelView
sourcefn http_create<'async_trait>(
__arg0: Json<<T::Entity as EntityTrait>::Model>
) -> Pin<Box<dyn Future<Output = Result<StatusCode>> + Send + 'async_trait>>where
Self: Send + 'async_trait,
fn http_create<'async_trait>(
__arg0: Json<<T::Entity as EntityTrait>::Model>
) -> Pin<Box<dyn Future<Output = Result<StatusCode>> + Send + 'async_trait>>where
Self: Send + 'async_trait,
POST a json body to /api and create a line in database return http 201 StatusCode::CREATED
fn set_model_primary_key(active_model: &mut T, value: u64)
sourcefn http_update<'async_trait>(
__arg0: Path<u64>,
__arg1: Json<<T::Entity as EntityTrait>::Model>
) -> Pin<Box<dyn Future<Output = Result<StatusCode>> + Send + 'async_trait>>where
Self: Send + 'async_trait,
fn http_update<'async_trait>(
__arg0: Path<u64>,
__arg1: Json<<T::Entity as EntityTrait>::Model>
) -> Pin<Box<dyn Future<Output = Result<StatusCode>> + Send + 'async_trait>>where
Self: Send + 'async_trait,
PUT a json body to /api/:id change a line in database return http 200 StatusCode::OK
fn check_instance_exists<'async_trait>(
pk: u64
) -> Pin<Box<dyn Future<Output = Result<<T::Entity as EntityTrait>::Model>> + Send + 'async_trait>>where
Self: Send + 'async_trait,
sourcefn http_list<'async_trait>(
__arg0: Query<Value>
) -> Pin<Box<dyn Future<Output = Result<Json<Value>>> + Send + 'async_trait>>where
Self: Send + 'async_trait,
fn http_list<'async_trait>(
__arg0: Query<Value>
) -> Pin<Box<dyn Future<Output = Result<Json<Value>>> + Send + 'async_trait>>where
Self: Send + 'async_trait,
GET list results with /api you can set page_size and page_num to page results with url like /api?page_size=10 or /api?page_size=10&page_num=1 return results with StatusCode::OK
sourcefn http_retrieve<'async_trait>(
__arg0: Path<u64>
) -> Pin<Box<dyn Future<Output = Result<Response>> + Send + 'async_trait>>where
Self: Send + 'async_trait,
fn http_retrieve<'async_trait>(
__arg0: Path<u64>
) -> Pin<Box<dyn Future<Output = Result<Response>> + Send + 'async_trait>>where
Self: Send + 'async_trait,
GET a single query result with /api/:id return http 200 with result or 404 if query not matched
sourcefn http_delete<'async_trait>(
__arg0: Path<u64>
) -> Pin<Box<dyn Future<Output = Result<StatusCode>> + Send + 'async_trait>>where
Self: Send + 'async_trait,
fn http_delete<'async_trait>(
__arg0: Path<u64>
) -> Pin<Box<dyn Future<Output = Result<StatusCode>> + Send + 'async_trait>>where
Self: Send + 'async_trait,
DELETE a instance with /api/:id return http 204 if success delete or http 404 if not matched or http 500 with error info
fn http_delete_all<'async_trait>(
) -> Pin<Box<dyn Future<Output = Result<StatusCode>> + Send + 'async_trait>>where
Self: Send + 'async_trait,
sourcefn exchange_primary_key(
id: u64
) -> <<T::Entity as EntityTrait>::PrimaryKey as PrimaryKeyTrait>::ValueType
fn exchange_primary_key( id: u64 ) -> <<T::Entity as EntityTrait>::PrimaryKey as PrimaryKeyTrait>::ValueType
change a value u64 into primary key
fn get_page_size(query: &Value) -> u64
fn inner_get_page_size(query: &Value) -> Result<u64>
fn page_size_param() -> &'static str
fn default_page_size() -> u64
fn get_page_num(query: &Value) -> u64
fn inner_get_page_num(query: &Value) -> Result<u64>
fn page_num_param() -> &'static str
fn default_page_num() -> u64
sourcefn http_router(nest_prefix: &'static str) -> Routerwhere
Self: Send + 'static,
fn http_router(nest_prefix: &'static str) -> Routerwhere
Self: Send + 'static,
get http routers with full operates