diff --git a/NOTES.md b/NOTES.md index 1972d82..93016dc 100644 --- a/NOTES.md +++ b/NOTES.md @@ -49,3 +49,50 @@ It's not like that is a bad thing, given this is also one of the downsides I wit sea-orm-cli generate entity -u postgresql://miniweb:miniweb@localhost:54321/miniweb -o entity/src --lib + + +## Admin Registry + +### Dynamic index functions + + +### Dynamic Repo Traits + +```rust +trait AdminRepository { + type Item; + type List; + + fn get_item(&self, id: usize) -> Option; + fn get_list(&self) -> Self::List; +} + +struct AdminRegistry { + repositories: HashMap>, +} + +impl AdminRegistry { + fn register(&mut self, name: &str, repository: R) { + self.repositories.insert(name.to_string(), Box::new(repository)); + } +} +``` + + +```rust +struct UserRepository; + +impl AdminRepository for UserRepository { + type Item = User; + type List = Vec; + + fn get_item(&self, id: usize) -> Option { + // Retrieve a single user + } + + fn get_list(&self) -> Vec { + // Retrieve a list of users + } +} + +``` \ No newline at end of file