Repository navigation
Closed
Labels
Description
Overview
Set up database connection management using libsql (Turso embedded) with user-selectable database location via Tauri.
Context: Database Path Strategy
Path is provided by Tauri client (not hardcoded in core):
- User-selectable: Folder picker dialog (can choose Dropbox/iCloud for auto-sync)
- Default fallback: Platform-specific app data directory
- Core library agnostic:
packages/corejust receivesPathBuf
Implementation Tasks
- Accept
PathBufparameter in DatabaseService::new() - Configure libsql database connection for local file
- Implement connection initialization and error handling
- Configure SQLite settings (WAL mode, foreign keys, JSON support)
- Set up database initialization (CREATE TABLE IF NOT EXISTS)
- Add connection error handling and recovery
Acceptance Criteria
- DatabaseService accepts
PathBuffrom Tauri - libsql connection works with any valid file path
- Connection initialization verifies database availability
- SQLite features enabled (foreign keys, WAL mode, JSON operators)
- Database initialization creates nodes + node_mentions tables
- Pure JSON schema (no migrations, no ALTER TABLE)
- Error handling for invalid paths or permission issues
- Works with user-selected folders (Dropbox, iCloud, etc.)
Technical Specifications
Database Service:
use libsql::Database;
use std::path::PathBuf;
pub struct DatabaseService {
db: Arc<Database>,
db_path: PathBuf,
}
impl DatabaseService {
pub async fn new(db_path: PathBuf) -> Result<Self> {
// Ensure parent directory exists
if let Some(parent) = db_path.parent() {
std::fs::create_dir_all(parent)?;
}
let db = Database::open(&db_path).await?;
Ok(Self { db: Arc::new(db), db_path })
}
}Tauri Integration (separate issue #110):
// User folder picker
#[tauri::command]
async fn select_db_location(app: AppHandle) -> Result<String> {
let folder = app.dialog().file().pick_folder().await?;
let db_path = folder.join("nodespace.db");
// Save preference for next launch
save_db_path_preference(&app, &db_path)?;
// Initialize database at chosen location
DatabaseService::new(db_path.clone()).await?;
Ok(db_path.to_string_lossy().to_string())
}Benefits:
- Users choose where database lives (local-first flexibility)
- Can select cloud-synced folders for backup
- Core library stays platform-agnostic
Activity
[-]Set up database connection and pooling with SQLx[/-][+]Set up database connection with libsql[/+]Set up database connection with libsql (addresses #101)
Fix clippy linting errors (addresses #101)
Set up database connection with libsql (#140)
Implement NodeService with CRUD operations (#104)
Implement NodeService with CRUD operations (#142)
Set up database connection with libsql (#140)
Implement NodeService with CRUD operations (#142)
Set up database connection with libsql (#140)
Implement NodeService with CRUD operations (#142)
Set up database connection with libsql (#140)
Implement NodeService with CRUD operations (#142)