File tree Expand file tree Collapse file tree 2 files changed +12
-0
lines changed
crates/bcr-ebill-persistence/src Expand file tree Collapse file tree 2 files changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -65,6 +65,16 @@ impl NostrContactStoreApi for SurrealNostrContactStore {
6565 Ok ( values. unwrap_or_default ( ) )
6666 }
6767
68+ /// Get all Nostr contacts from the store.
69+ async fn get_all ( & self ) -> Result < Vec < NostrContact > > {
70+ let result: Vec < NostrContactDb > = self . db . select_all ( Self :: TABLE ) . await ?;
71+ let values = result
72+ . into_iter ( )
73+ . map ( |c| c. to_owned ( ) . try_into ( ) . ok ( ) )
74+ . collect :: < Option < Vec < NostrContact > > > ( ) ;
75+ Ok ( values. unwrap_or_default ( ) )
76+ }
77+
6878 /// Find a Nostr contact by the npub. This is the public Nostr key of the contact.
6979 async fn by_npub ( & self , npub : & NostrPublicKey ) -> Result < Option < NostrContact > > {
7080 let result: Option < NostrContactDb > = self . db . select_one ( Self :: TABLE , npub. to_hex ( ) ) . await ?;
Original file line number Diff line number Diff line change @@ -84,6 +84,8 @@ pub trait NostrContactStoreApi: ServiceTraitBounds {
8484 async fn by_node_id ( & self , node_id : & NodeId ) -> Result < Option < NostrContact > > ;
8585 /// Find multiple Nostr contacts by their node ids.
8686 async fn by_node_ids ( & self , node_ids : Vec < NodeId > ) -> Result < Vec < NostrContact > > ;
87+ /// Get all Nostr contacts from the store.
88+ async fn get_all ( & self ) -> Result < Vec < NostrContact > > ;
8789 /// Find a Nostr contact by the npub. This is the public Nostr key of the contact.
8890 async fn by_npub ( & self , npub : & NostrPublicKey ) -> Result < Option < NostrContact > > ;
8991 /// Creates a new or updates an existing Nostr contact.
You can’t perform that action at this time.
0 commit comments