Persist links to a database

This commit is contained in:
Marc Plano-Lesay 2025-04-30 21:45:08 +10:00
parent 17fb0c1856
commit b157985bf3
Signed by: kernald
GPG key ID: 66A41B08CC62A6CF
10 changed files with 451 additions and 44 deletions

26
src/models.rs Normal file
View file

@ -0,0 +1,26 @@
use crate::schema::magnets;
use chrono::NaiveDateTime;
use diesel::prelude::*;
#[derive(Queryable, Selectable)]
#[diesel(table_name = magnets)]
#[diesel(check_for_backend(diesel::sqlite::Sqlite))]
pub struct Magnet {
pub id: Option<i32>,
pub title: String,
pub submitter: String,
pub subreddit: String,
pub link: String,
pub published_at: NaiveDateTime,
}
#[derive(Insertable)]
#[diesel(table_name = magnets)]
#[diesel(check_for_backend(diesel::sqlite::Sqlite))]
pub struct NewMagnet<'a> {
pub title: &'a str,
pub submitter: &'a str,
pub subreddit: &'a str,
pub link: &'a str,
pub published_at: &'a NaiveDateTime,
}