1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
//! File Attachments System
//!
//! This module stores file references inside a JSON or JSONB model column.
//!
//! Use it when the database needs to keep attachment metadata such as keys,
//! filenames, and timestamps, but the actual file bytes live somewhere else.
//!
//! The two supported shapes are:
//! - single-file relations such as `thumbnail` or `avatar`
//! - multi-file relations such as `images` or `documents`
//!
//! If attachment calls appear to succeed but nothing is persisted, the usual
//! cause is that the model was not saved after mutating the in-memory `files`
//! payload.
//!
//! Typical workflow:
//! - declare the `files` JSON or JSONB column plus `#[tideorm(has_one_file = ...)]` or `#[tideorm(has_many_files = ...)]`
//! - use `attach()` or `attach_many()` to append metadata-backed file references
//! - use `detach()` or `sync()` when the relation should be removed or replaced wholesale
//! - save the model afterward so the updated payload is persisted
//!
//! ## File Metadata
//!
//! Each attachment stores:
//! - `key`: The file path/key
//! - `filename`: Extracted filename
//! - `created_at`: Timestamp when attached
//! - Additional fields can be added via `attach_with_metadata`
pub use AttachmentError;
pub use FileAttachment;
pub use FilesData;
pub use HasAttachments;