summaryrefslogtreecommitdiff
path: root/src/repository/models.rs
diff options
context:
space:
mode:
authorSanto Cariotti <santo@dcariotti.me>2021-03-14 12:55:21 +0100
committerSanto Cariotti <santo@dcariotti.me>2021-03-14 12:55:21 +0100
commit6acc53da212e7506fd33534fd5cf9baa0d01e4ea (patch)
treefa9c35bace83a46f74ae11ad23eb58f47eba2161 /src/repository/models.rs
parentf7932c366bab2f5d0726f4d1cdf5b9dbeddf92eb (diff)
chore: add docs
Diffstat (limited to 'src/repository/models.rs')
-rw-r--r--src/repository/models.rs5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/repository/models.rs b/src/repository/models.rs
index 54a93d7..c480cbe 100644
--- a/src/repository/models.rs
+++ b/src/repository/models.rs
@@ -9,6 +9,7 @@ use uuid::Uuid;
#[derive(Serialize, Deserialize, PostgresMapper)]
#[pg_mapper(table = "repository")]
+/// Repository model
pub struct Repository {
pub id: Uuid,
pub url: String,
@@ -18,6 +19,9 @@ pub struct Repository {
}
impl Repository {
+ /// Find all repositories inside the database.
+ /// Make a select query and order the repositories by descrescent updated
+ /// datetime
pub async fn find_all(pool: Pool) -> Result<Vec<Repository>, AppError> {
let client = get_client(pool.clone()).await.unwrap();
let statement = client
@@ -34,6 +38,7 @@ impl Repository {
Ok(repos)
}
+ /// Find a repository with an `id` equals to an Uuid element
pub async fn find(pool: Pool, id: &Uuid) -> Result<Repository, AppError> {
let client = get_client(pool.clone()).await.unwrap();
let statement = client