From 3d559f8ae5c81450d11b6f5093735e6db8229502 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gabor=20K=C3=B6rber?= Date: Sat, 11 May 2024 13:31:15 +0200 Subject: [PATCH] code: starting with file repository --- src/admin_examples/file_repository.rs | 64 +++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 src/admin_examples/file_repository.rs diff --git a/src/admin_examples/file_repository.rs b/src/admin_examples/file_repository.rs new file mode 100644 index 0000000..114d1ec --- /dev/null +++ b/src/admin_examples/file_repository.rs @@ -0,0 +1,64 @@ +use crate::admin::domain::*; +use async_trait::async_trait; +use serde_json::Value; + +struct Repository {} + +impl Repository {} + +#[async_trait] +impl AdminRepository for Repository { + async fn info(&self, _: &RepositoryContext) -> RepositoryInfo { + RepoInfo { + name: "My Empty Repository", + lookup_key: "id", + display_list: &["id"], + fields: &[], + } + .into() + } + + // GET on item collection. + async fn list(&self, model: &RepositoryContext) -> RepositoryList { + RepositoryList::Empty + } + + // POST on item collection. + async fn create( + &mut self, + model: &RepositoryContext, + mut data: Value, + ) -> Option { + None + } + + // GET single item. + async fn get(&self, model: &RepositoryContext, id: LookupKey) -> Option { + None + } + + // PATCH single item. + async fn update( + &mut self, + model: &RepositoryContext, + id: LookupKey, + data: Value, + ) -> Option { + None + } + + // PUT single item. + async fn replace( + &mut self, + model: &RepositoryContext, + id: LookupKey, + data: Value, + ) -> Option { + None + } + + // DELETE single item. + async fn delete(&mut self, _: &RepositoryContext, id: LookupKey) -> Option { + None + } +}