code: starting with file repository
This commit is contained in:
parent
eebf8b01a0
commit
3d559f8ae5
64
src/admin_examples/file_repository.rs
Normal file
64
src/admin_examples/file_repository.rs
Normal file
@ -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<RepositoryItem> {
|
||||
None
|
||||
}
|
||||
|
||||
// GET single item.
|
||||
async fn get(&self, model: &RepositoryContext, id: LookupKey) -> Option<RepositoryItem> {
|
||||
None
|
||||
}
|
||||
|
||||
// PATCH single item.
|
||||
async fn update(
|
||||
&mut self,
|
||||
model: &RepositoryContext,
|
||||
id: LookupKey,
|
||||
data: Value,
|
||||
) -> Option<RepositoryItem> {
|
||||
None
|
||||
}
|
||||
|
||||
// PUT single item.
|
||||
async fn replace(
|
||||
&mut self,
|
||||
model: &RepositoryContext,
|
||||
id: LookupKey,
|
||||
data: Value,
|
||||
) -> Option<RepositoryItem> {
|
||||
None
|
||||
}
|
||||
|
||||
// DELETE single item.
|
||||
async fn delete(&mut self, _: &RepositoryContext, id: LookupKey) -> Option<Value> {
|
||||
None
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user