68c7aad179
The code is divided in three crates: - plume-common, for the ActivityPub module, and some common utils - plume-models, for the models and database-related code - plume, the app itself This new organization will allow to test it more easily, but also to create other tools that only reuse a little part of the code (for instance a Wordpress import tool, that would just use the plume-models crate)
27 lines
557 B
Rust
27 lines
557 B
Rust
use diesel::{self, PgConnection, QueryDsl, RunQueryDsl, ExpressionMethods};
|
|
|
|
use posts::Post;
|
|
use users::User;
|
|
use schema::post_authors;
|
|
|
|
#[derive(Queryable, Identifiable, Associations)]
|
|
#[belongs_to(Post)]
|
|
#[belongs_to(User, foreign_key = "author_id")]
|
|
pub struct PostAuthor {
|
|
pub id: i32,
|
|
pub post_id: i32,
|
|
pub author_id: i32
|
|
}
|
|
|
|
#[derive(Insertable)]
|
|
#[table_name = "post_authors"]
|
|
pub struct NewPostAuthor {
|
|
pub post_id: i32,
|
|
pub author_id: i32
|
|
}
|
|
|
|
impl PostAuthor {
|
|
insert!(post_authors, NewPostAuthor);
|
|
get!(post_authors);
|
|
}
|