diff --git a/PLAN.md b/PLAN.md index 8cf83d3..ef92773 100644 --- a/PLAN.md +++ b/PLAN.md @@ -12,7 +12,7 @@ Private helpers (e.g., internal `fn` without `pub`) are not flagged, as they don ### Files with Incomplete Rustdoc -1. **src/modes/server/pages.rs** +1. **src/modes/server/pages.rs** [DONE] - `ListQueryParams` struct: Missing doc comment entirely. - `default_sort()` and `default_count()` functions: No doc comments. - `add_routes()` function: Partial doc (missing examples or errors). @@ -23,7 +23,7 @@ Private helpers (e.g., internal `fn` without `pub`) are not flagged, as they don - `build_item_details()` function: No doc comment. - Overall: The file has some inline comments but lacks comprehensive rustdoc for the public API. -2. **src/db.rs** +2. **src/db.rs** [DONE - first 10 items] - `Item`, `Tag`, and `Meta` structs: Partial docs (fields documented, but missing overall struct description or examples). - `open()` function: Good doc, but missing error examples. - `insert_item()` function: Partial (missing full error details). diff --git a/src/db.rs b/src/db.rs index bcfcc0b..4d8ad81 100644 --- a/src/db.rs +++ b/src/db.rs @@ -456,6 +456,34 @@ pub fn query_upsert_meta(conn: &Connection, meta: Meta) -> Result<()> { Ok(()) } +/// Stores a metadata entry, deleting it if the value is empty. +/// +/// Handles both insertion/update and deletion based on value presence. +/// +/// # Arguments +/// +/// * `conn` - Database connection. +/// * `meta` - Metadata entry to store (empty value triggers deletion). +/// +/// # Returns +/// +/// * `Result<()>` - Success or error if the operation fails. +/// +/// # Errors +/// +/// * Database errors during insert/update/delete. +/// +/// # Examples +/// +/// ``` +/// // Insert new metadata +/// let meta = Meta { id: 1, name: "source".to_string(), value: "cli".to_string() }; +/// db::store_meta(&conn, meta)?; +/// +/// // Delete metadata with empty value +/// let meta = Meta { id: 1, name: "temp".to_string(), value: "".to_string() }; +/// db::store_meta(&conn, meta)?; +/// ``` /// Stores a metadata entry, deleting it if the value is empty. /// /// Handles both insertion/update and deletion based on value presence.