diff --git a/src/admin/domain.rs b/src/admin/domain.rs index 464bc71..01061c4 100644 --- a/src/admin/domain.rs +++ b/src/admin/domain.rs @@ -367,6 +367,12 @@ pub mod repository { id: LookupKey, data: Value, ) -> Option; + async fn replace( + &mut self, + context: &RepositoryContext, + id: LookupKey, + data: Value, + ) -> Option; async fn delete(&mut self, context: &RepositoryContext, id: LookupKey) -> Option; } } diff --git a/src/admin_examples/empty_repository.rs b/src/admin_examples/empty_repository.rs index 02952cb..114d1ec 100644 --- a/src/admin_examples/empty_repository.rs +++ b/src/admin_examples/empty_repository.rs @@ -18,14 +18,12 @@ impl AdminRepository for Repository { .into() } - async fn get(&self, model: &RepositoryContext, id: LookupKey) -> Option { - None - } - + // GET on item collection. async fn list(&self, model: &RepositoryContext) -> RepositoryList { RepositoryList::Empty } + // POST on item collection. async fn create( &mut self, model: &RepositoryContext, @@ -34,6 +32,12 @@ impl AdminRepository for Repository { None } + // GET single item. + async fn get(&self, model: &RepositoryContext, id: LookupKey) -> Option { + None + } + + // PATCH single item. async fn update( &mut self, model: &RepositoryContext, @@ -43,6 +47,17 @@ impl AdminRepository for Repository { 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 } diff --git a/src/admin_examples/static_repository.rs b/src/admin_examples/static_repository.rs index 678437c..18c864b 100644 --- a/src/admin_examples/static_repository.rs +++ b/src/admin_examples/static_repository.rs @@ -124,6 +124,15 @@ impl AdminRepository for MyStaticRepository { None } + async fn replace( + &mut self, + model: &RepositoryContext, + id: LookupKey, + data: Value, + ) -> Option { + self.update(model, id, data).await + } + async fn delete(&mut self, _: &RepositoryContext, id: LookupKey) -> Option { debug!("Would delete: {}", id); diff --git a/src/admin_examples/user_repository.rs b/src/admin_examples/user_repository.rs index 738aff7..d8cb7b6 100644 --- a/src/admin_examples/user_repository.rs +++ b/src/admin_examples/user_repository.rs @@ -46,6 +46,15 @@ impl AdminRepository for UserRepository { None } + async fn replace( + &mut self, + model: &RepositoryContext, + id: LookupKey, + data: Value, + ) -> Option { + None + } + async fn delete(&mut self, _: &RepositoryContext, id: LookupKey) -> Option { None }