Files
fforte/lib/interfaces/i_db.dart

66 lines
2.1 KiB
Dart

// * Interface defining the contract for database operations
// * Used by both PlaceDBHelper and ExcursionDBHelper
// * Provides a common set of operations for managing entries and templates
import 'package:sqflite/sqflite.dart';
/// Interface for database operations
/// Implements the Repository pattern for database access
abstract interface class IDb {
/// Get the database instance
Future<Database> get dB;
/// Initialize the database and create necessary tables
initDatabases();
/// Create database schema
/// @param excursionDB Database instance
/// @param version Schema version number
onCreateDatabases(Database excursionDB, int version);
/// Add a new main entry
/// @param excursion Map of entry data
/// @return ID of the new entry
Future<int> addMainEntry(Map<String, String> excursion);
/// Update an existing main entry
/// @param excursion Map of updated entry data
/// @return Number of rows affected
Future<int> updateMainEntry(Map<String, String> excursion);
/// Mark an entry as sent to the server
/// @param id ID of the entry to update
Future<void> updateSent(int id);
/// Add a new template entry
/// @param templates Map of template data
/// @return ID of the new template
Future<int> addTemplate(Map<String, String> templates);
/// Update an existing template
/// @param template Map of updated template data
Future<void> updateTemplate(Map<String, String> template);
/// Get all main entries from the database
/// @return List of all entries
Future<List<Map<String, dynamic>>> getAllMainEntries();
/// Get all templates from the database
/// @return List of all templates
Future<List<Map<String, dynamic>>> getAllTemplates();
/// Delete all main entries from the database
Future<void> deleteAllMainEntries();
/// Delete all templates from the database
Future<void> deleteAllTemplates();
/// Delete a specific template
/// @param id ID of the template to delete
Future<void> deleteTemplateById(String id);
/// Delete a specific main entry
/// @param id ID of the entry to delete
Future<void> deleteMainEntryById(String id);
}