Skip to content

Commit

Permalink
cleanup: move used models up, sort alphabetically
Browse files Browse the repository at this point in the history
  • Loading branch information
phildenhoff committed Oct 29, 2024
1 parent d599b0e commit 295eeda
Showing 1 changed file with 30 additions and 28 deletions.
58 changes: 30 additions & 28 deletions src-tauri/libcalibre/src/models.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,36 @@ use crate::entities::book::Book;

use super::schema::*;

#[derive(Queryable, Selectable, Identifiable, Insertable)]
#[diesel(table_name = authors)]
#[diesel(check_for_backend(diesel::sqlite::Sqlite))]
pub struct Author {
pub id: i32,
pub name: String,
pub sort: Option<String>,
pub link: String,
}

#[derive(Identifiable, Associations, Queryable, Selectable, Insertable)]
#[diesel(belongs_to(Book, foreign_key = book))]
#[diesel(belongs_to(Author, foreign_key = author))]
#[diesel(table_name = books_authors_link)]
pub struct BookAuthorLink {
pub id: Option<i32>,
pub book: i32,
pub author: i32,
}

#[derive(Queryable, Selectable)]
#[diesel(table_name = identifiers)]
#[diesel(check_for_backend(diesel::sqlite::Sqlite))]
pub struct Identifier {
pub id: i32,
pub book: i32,
pub type_: String,
pub val: String,
}

// #[derive(Queryable, Selectable)]
// #[diesel(table_name = annotations)]
// #[diesel(check_for_backend(diesel::sqlite::Sqlite))]
Expand All @@ -20,15 +50,6 @@ use super::schema::*;
// pub searchable_text: String,
// }

#[derive(Queryable, Selectable, Identifiable, Insertable)]
#[diesel(table_name = authors)]
#[diesel(check_for_backend(diesel::sqlite::Sqlite))]
pub struct Author {
pub id: i32,
pub name: String,
pub sort: Option<String>,
pub link: String,
}

// #[derive(Queryable, Selectable)]
// #[diesel(table_name = comments)]
Expand Down Expand Up @@ -73,16 +94,6 @@ pub struct Author {
// pub script: String,
// }

#[derive(Queryable, Selectable)]
#[diesel(table_name = identifiers)]
#[diesel(check_for_backend(diesel::sqlite::Sqlite))]
pub struct Identifier {
pub id: i32,
pub book: i32,
pub type_: String,
pub val: String,
}

// #[derive(Queryable, Selectable)]
// #[diesel(table_name = languages)]
// #[diesel(check_for_backend(diesel::sqlite::Sqlite))]
Expand Down Expand Up @@ -164,15 +175,6 @@ pub struct Identifier {
// pub name: String,
// }

#[derive(Identifiable, Associations, Queryable, Selectable, Insertable)]
#[diesel(belongs_to(Book, foreign_key = book))]
#[diesel(belongs_to(Author, foreign_key = author))]
#[diesel(table_name = books_authors_link)]
pub struct BookAuthorLink {
pub id: Option<i32>,
pub book: i32,
pub author: i32,
}

// #[derive(Queryable, Selectable)]
// #[diesel(table_name = books_languages_link)]
Expand Down

0 comments on commit 295eeda

Please sign in to comment.