66 lines
1.5 KiB
Rust
66 lines
1.5 KiB
Rust
use super::schema::{libraries, samples, samples_tags, tags};
|
|
use diesel::prelude::*;
|
|
|
|
#[derive(Debug, Queryable, Selectable)]
|
|
#[diesel(table_name = libraries)]
|
|
#[diesel(check_for_backend(diesel::sqlite::Sqlite))]
|
|
pub struct Library {
|
|
pub id: i32,
|
|
pub name: String,
|
|
}
|
|
|
|
#[derive(Debug, Insertable)]
|
|
#[diesel(table_name = libraries)]
|
|
pub struct NewLibrary<'a> {
|
|
pub name: &'a str,
|
|
}
|
|
|
|
#[derive(Debug, Identifiable, Queryable, Selectable)]
|
|
#[diesel(table_name = samples)]
|
|
pub struct Sample {
|
|
pub id: i32,
|
|
pub name: String,
|
|
pub path: String,
|
|
pub bpm: Option<f32>,
|
|
pub key: Option<String>, // For now this seems to be reasonable, instead of creating a giant enum.
|
|
}
|
|
|
|
#[derive(Debug, Insertable)]
|
|
#[diesel(table_name = samples)]
|
|
pub struct NewSample<'a> {
|
|
pub name: &'a str,
|
|
pub path: &'a str,
|
|
pub bpm: Option<f32>,
|
|
pub key: Option<&'a str>,
|
|
}
|
|
|
|
#[derive(Debug, Identifiable, Queryable, Selectable)]
|
|
#[diesel(table_name = tags)]
|
|
pub struct Tag {
|
|
pub id: i32,
|
|
pub name: String,
|
|
}
|
|
|
|
#[derive(Debug, Insertable)]
|
|
#[diesel(table_name = tags)]
|
|
pub struct NewTag<'a> {
|
|
pub name: &'a str,
|
|
}
|
|
|
|
#[derive(Debug, Identifiable, Associations, Queryable, Selectable)]
|
|
#[diesel(belongs_to(Sample))]
|
|
#[diesel(belongs_to(Tag))]
|
|
#[diesel(table_name = samples_tags)]
|
|
pub struct SampleTag {
|
|
pub id: i32,
|
|
pub sample_id: i32,
|
|
pub tag_id: i32,
|
|
}
|
|
|
|
#[derive(Debug, Insertable)]
|
|
#[diesel(table_name = samples_tags)]
|
|
pub struct NewSampleTag {
|
|
pub sample_id: i32,
|
|
pub tag_id: i32,
|
|
}
|