add support for media_group
This commit is contained in:
parent
8e3f1496ae
commit
92c4f803eb
@ -239,11 +239,28 @@ impl DB {
|
|||||||
Ok(deleted_count)
|
Ok(deleted_count)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub async fn drop_media_except(
|
||||||
|
&mut self,
|
||||||
|
literal: &str,
|
||||||
|
except_group: &str,
|
||||||
|
) -> Result<usize, Box<dyn std::error::Error>> {
|
||||||
|
use self::schema::media::dsl::*;
|
||||||
|
let conn = &mut self.pool.get().await.unwrap();
|
||||||
|
|
||||||
|
let deleted_count =
|
||||||
|
diesel::delete(media.filter(token.eq(literal).and(media_group_id.ne(except_group))))
|
||||||
|
.execute(conn)
|
||||||
|
.await?;
|
||||||
|
|
||||||
|
Ok(deleted_count)
|
||||||
|
}
|
||||||
|
|
||||||
pub async fn add_media(
|
pub async fn add_media(
|
||||||
&mut self,
|
&mut self,
|
||||||
literal: &str,
|
literal: &str,
|
||||||
mediatype: &str,
|
mediatype: &str,
|
||||||
fileid: &str,
|
fileid: &str,
|
||||||
|
media_group: Option<&str>,
|
||||||
) -> Result<Media, Box<dyn std::error::Error>> {
|
) -> Result<Media, Box<dyn std::error::Error>> {
|
||||||
use self::schema::media::dsl::*;
|
use self::schema::media::dsl::*;
|
||||||
let conn = &mut self.pool.get().await.unwrap();
|
let conn = &mut self.pool.get().await.unwrap();
|
||||||
@ -253,6 +270,7 @@ impl DB {
|
|||||||
token.eq(literal),
|
token.eq(literal),
|
||||||
media_type.eq(mediatype),
|
media_type.eq(mediatype),
|
||||||
file_id.eq(fileid),
|
file_id.eq(fileid),
|
||||||
|
media_group_id.eq(media_group),
|
||||||
))
|
))
|
||||||
.get_result::<Media>(conn)
|
.get_result::<Media>(conn)
|
||||||
.await?;
|
.await?;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user