diff --git a/acrate-core/src/meta.rs b/acrate-core/src/meta.rs index a5b4d2a..bcfd200 100644 --- a/acrate-core/src/meta.rs +++ b/acrate-core/src/meta.rs @@ -22,6 +22,7 @@ pub struct MetaLink { pub rel: String, pub type_: Option, pub href: Option, + pub template: Option, } #[derive(Debug, Queryable, QueryableByName, Identifiable, Selectable, Insertable, Associations)] @@ -34,6 +35,16 @@ pub struct MetaLinkProperty { pub value: Option, } +#[derive(Debug, Queryable, QueryableByName, Identifiable, Selectable, Insertable, Associations)] +#[diesel(belongs_to(MetaLink))] +#[diesel(table_name = schema::meta_link_titles)] +pub struct MetaLinkTitle { + pub id: Uuid, + pub meta_link_id: Uuid, + pub language: String, + pub value: String, +} + #[derive(Debug, Queryable, QueryableByName, Identifiable, Selectable, Insertable)] #[diesel(table_name = schema::meta_properties)] pub struct MetaProperty { @@ -44,7 +55,6 @@ pub struct MetaProperty { pub value: Option, } - impl MetaAlias { pub async fn query_matching(conn: &mut AsyncPgConnection, doc: &str, subject: &str) -> QueryResult> { use diesel::prelude::*; @@ -88,6 +98,15 @@ impl MetaLink { .load(conn) .await } + + pub async fn query_titles(&self, conn: &mut AsyncPgConnection) -> QueryResult> { + use diesel::prelude::*; + use diesel_async::RunQueryDsl; + + MetaLinkTitle::belonging_to(self) + .load(conn) + .await + } } impl MetaProperty {