docs: Update function documentation to use block comments
Co-authored-by: aider (openai/andrew/openrouter/sonoma-sky-alpha) <aider@aider.chat>
This commit is contained in:
81
src/db.rs
81
src/db.rs
@@ -9,46 +9,49 @@ use std::collections::HashMap;
|
||||
use std::path::PathBuf;
|
||||
use std::rc::Rc;
|
||||
|
||||
/// Database module for the Keep application.
|
||||
///
|
||||
/// This module provides SQLite database operations for storing and retrieving
|
||||
/// items, tags, and metadata. It includes schema migrations, CRUD operations,
|
||||
/// and query utilities for efficient data access.
|
||||
///
|
||||
/// # Schema
|
||||
///
|
||||
/// The database uses three main tables:
|
||||
/// - `items`: Core item information (ID, timestamp, size, compression).
|
||||
/// - `tags`: Item-tag associations (many-to-many).
|
||||
/// - `metas`: Item-metadata associations (many-to-many).
|
||||
///
|
||||
/// Foreign keys are enforced with cascading deletes. Indexes on tag and meta
|
||||
/// names improve query performance.
|
||||
///
|
||||
/// # Migrations
|
||||
///
|
||||
/// Automatic schema migrations are applied on database open using
|
||||
/// `rusqlite_migration`. The current schema includes:
|
||||
/// - Items table with auto-increment ID.
|
||||
/// - Tags and metas tables with composite primary keys.
|
||||
/// - Indexes on tag and meta names.
|
||||
///
|
||||
/// # Usage
|
||||
///
|
||||
/// Open a connection:
|
||||
/// ```
|
||||
/// let conn = db::open(PathBuf::from("keep.db"))?;
|
||||
/// ```
|
||||
/// Insert an item:
|
||||
/// ```
|
||||
/// let item = db::Item { id: None, ts: Utc::now(), size: None, compression: "lz4".to_string() };
|
||||
/// let id = db::insert_item(&conn, item)?;
|
||||
/// ```
|
||||
/*
|
||||
Database module for the Keep application.
|
||||
|
||||
This module provides SQLite database operations for storing and retrieving
|
||||
items, tags, and metadata. It includes schema migrations, CRUD operations,
|
||||
and query utilities for efficient data access.
|
||||
|
||||
# Schema
|
||||
|
||||
The database uses three main tables:
|
||||
- `items`: Core item information (ID, timestamp, size, compression).
|
||||
- `tags`: Item-tag associations (many-to-many).
|
||||
- `metas`: Item-metadata associations (many-to-many).
|
||||
|
||||
Foreign keys are enforced with cascading deletes. Indexes on tag and meta
|
||||
names improve query performance.
|
||||
|
||||
# Migrations
|
||||
|
||||
Automatic schema migrations are applied on database open using
|
||||
`rusqlite_migration`. The current schema includes:
|
||||
- Items table with auto-increment ID.
|
||||
- Tags and metas tables with composite primary keys.
|
||||
- Indexes on tag and meta names.
|
||||
|
||||
# Usage
|
||||
|
||||
Open a connection:
|
||||
```
|
||||
let conn = db::open(PathBuf::from("keep.db"))?;
|
||||
```
|
||||
Insert an item:
|
||||
```
|
||||
let item = db::Item { id: None, ts: Utc::now(), size: None, compression: "lz4".to_string() };
|
||||
let id = db::insert_item(&conn, item)?;
|
||||
```
|
||||
*/
|
||||
|
||||
lazy_static! {
|
||||
/// Database schema migrations for the Keep application.
|
||||
///
|
||||
/// Defines the sequence of migrations to create and update the schema.
|
||||
/// Applied automatically when opening a database connection.
|
||||
// Database schema migrations for the Keep application.
|
||||
//
|
||||
// Defines the sequence of migrations to create and update the schema.
|
||||
// Applied automatically when opening a database connection.
|
||||
static ref MIGRATIONS: Migrations<'static> = Migrations::new(vec![
|
||||
M::up(
|
||||
"CREATE TABLE items(
|
||||
|
||||
@@ -60,17 +60,17 @@ use crate::common::status::{MetaPluginInfo, CompressionInfo};
|
||||
|
||||
|
||||
fn build_meta_plugin_table(meta_plugin_info: &std::collections::HashMap<String, MetaPluginInfo>) -> Table {
|
||||
/// Builds a formatted table displaying meta plugin information.
|
||||
///
|
||||
/// Sorts plugins by name and displays options as YAML and outputs as a list.
|
||||
///
|
||||
/// # Arguments
|
||||
///
|
||||
/// * `meta_plugin_info` - HashMap of meta plugin information.
|
||||
///
|
||||
/// # Returns
|
||||
///
|
||||
/// A formatted `comfy_table::Table`.
|
||||
// Builds a formatted table displaying meta plugin information.
|
||||
//
|
||||
// Sorts plugins by name and displays options as YAML and outputs as a list.
|
||||
//
|
||||
// # Arguments
|
||||
//
|
||||
// * `meta_plugin_info` - HashMap of meta plugin information.
|
||||
//
|
||||
// # Returns
|
||||
//
|
||||
// A formatted `comfy_table::Table`.
|
||||
let mut meta_plugin_table = crate::modes::common::create_table(true);
|
||||
|
||||
meta_plugin_table.set_header(vec![
|
||||
@@ -291,20 +291,20 @@ pub fn mode_status_plugins(
|
||||
data_path: PathBuf,
|
||||
db_path: PathBuf,
|
||||
) -> Result<(), anyhow::Error> {
|
||||
/// Displays status information for available plugins in the specified output format.
|
||||
///
|
||||
/// Generates status using StatusService and renders as table, JSON, or YAML.
|
||||
///
|
||||
/// # Arguments
|
||||
///
|
||||
/// * `cmd` - Mutable Clap command.
|
||||
/// * `settings` - Application settings.
|
||||
/// * `data_path` - Data directory path.
|
||||
/// * `db_path` - Database path.
|
||||
///
|
||||
/// # Returns
|
||||
///
|
||||
/// `Ok(())` on success, or anyhow::Error.
|
||||
// Displays status information for available plugins in the specified output format.
|
||||
//
|
||||
// Generates status using StatusService and renders as table, JSON, or YAML.
|
||||
//
|
||||
// # Arguments
|
||||
//
|
||||
// * `cmd` - Mutable Clap command.
|
||||
// * `settings` - Application settings.
|
||||
// * `data_path` - Data directory path.
|
||||
// * `db_path` - Database path.
|
||||
//
|
||||
// # Returns
|
||||
//
|
||||
// `Ok(())` on success, or anyhow::Error.
|
||||
debug!("STATUS_PLUGINS: Starting mode_status_plugins function");
|
||||
|
||||
let status_service = crate::services::status_service::StatusService::new();
|
||||
|
||||
Reference in New Issue
Block a user