1use crate::{CreateNote, Error, Note, NoteQuery, TagCount, UpdateNote};
2
3#[async_trait::async_trait(?Send)]
8pub trait Database {
9 async fn add_note(&self, note: CreateNote) -> Result<i64, Error>;
11
12 async fn get_note(&self, id: i64) -> Result<Option<Note>, Error>;
14
15 async fn list_notes(&self, query: NoteQuery) -> Result<Vec<Note>, Error>;
17
18 async fn count_notes(&self, query: NoteQuery) -> Result<i64, Error>;
20
21 async fn update_note(&self, id: i64, update: UpdateNote) -> Result<bool, Error>;
23
24 async fn delete_note(&self, id: i64) -> Result<bool, Error>;
26
27 async fn list_tags(&self) -> Result<Vec<TagCount>, Error>;
29
30 async fn grep(
32 &self,
33 pattern: &str,
34 tags: Option<&[String]>,
35 case_sensitive: bool,
36 ) -> Result<Vec<Note>, Error>;
37}