fixes
This commit is contained in:
@@ -902,3 +902,36 @@ pub async fn delete_note_file(
|
||||
.await?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub async fn find_pad_file(
|
||||
pool: &Database,
|
||||
pad_id: i64,
|
||||
file_id: i64,
|
||||
) -> Result<Option<NoteFile>, sqlx::Error> {
|
||||
if pool.kind() == DatabaseKind::Sqlite {
|
||||
return Ok(sqlx::query_as::<_, SqliteNoteFile>(queries::Q046)
|
||||
.bind(file_id)
|
||||
.bind(pad_id)
|
||||
.fetch_optional(pool.pool())
|
||||
.await?
|
||||
.map(NoteFile::from));
|
||||
}
|
||||
sqlx::query_as::<_, NoteFile>(queries::get(pool.kind(), queries::Q046))
|
||||
.bind(file_id)
|
||||
.bind(pad_id)
|
||||
.fetch_optional(pool.pool())
|
||||
.await
|
||||
}
|
||||
|
||||
pub async fn delete_pad_file(
|
||||
pool: &Database,
|
||||
pad_id: i64,
|
||||
file_id: i64,
|
||||
) -> Result<(), sqlx::Error> {
|
||||
sqlx::query(queries::get(pool.kind(), queries::Q047))
|
||||
.bind(file_id)
|
||||
.bind(pad_id)
|
||||
.execute(pool.pool())
|
||||
.await?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user