forge
Explore
Log in

Don't you dare go Hollow

hezarfen_backend

Clone
★ 0

0 watching0 forksRust8.3 MiB6d68754Ahmet Kaan Gümüş2 months ago566 commits

course_note_file.rs48 lines, 1.7 KiBHistoryRawDownload
1//! Course-note-file workflows: the attachment paths the course-notes surface
2//! drives. The queries live in [`crate::db::course_note_file`]; blob
3//! unlinking and the AI re-index stay in the web layer.
4
5use crate::database::Database;
6use crate::db::course_note_file;
7use crate::domain::course_note::CourseNoteId;
8use crate::domain::course_note_file::{CourseNoteFile, CourseNoteFileId};
9use crate::error::AppError;
10
11/// Persist a row assembled by [`CourseNoteFile::new`]; refuses with a
12/// conflict once the note holds its cap.
13pub async fn insert(db: &Database, file: CourseNoteFile) -> Result<CourseNoteFile, AppError> {
14 course_note_file::insert(db, file).await
15}
16
17/// Read a file's row by id alone — the AI bridge reaches the note *through*
18/// the file, so no note scoping happens here.
19pub async fn read(
20 db: &Database,
21 id: &CourseNoteFileId,
22) -> Result<Option<CourseNoteFile>, AppError> {
23 course_note_file::read(db, id).await
24}
25
26/// Read a file's row only if it belongs to `note`.
27pub async fn read_for(
28 db: &Database,
29 id: &CourseNoteFileId,
30 note: &CourseNoteId,
31) -> Result<Option<CourseNoteFile>, AppError> {
32 course_note_file::read_for(db, id, note).await
33}
34
35pub async fn list_for(
36 db: &Database,
37 note: &CourseNoteId,
38 limit: Option<i64>,
39 offset: i64,
40) -> Result<(Vec<CourseNoteFile>, i64), AppError> {
41 course_note_file::list_for(db, note, limit, offset).await
42}
43
44/// Delete the row and hand its slot back in the same transaction; the
45/// returned row is exactly whose blob the caller may unlink.
46pub async fn delete(db: &Database, file: CourseNoteFile) -> Result<CourseNoteFile, AppError> {
47 course_note_file::delete(db, file).await
48}