Squash merge feature/fts into master
This commit is contained in:
@@ -3,8 +3,10 @@ import 'package:journaler/db.dart';
|
||||
class Note {
|
||||
final String date;
|
||||
String content;
|
||||
String?
|
||||
snippet; // Optional field to hold highlighted snippets for search results
|
||||
|
||||
Note({required this.date, required this.content});
|
||||
Note({required this.date, required this.content, this.snippet});
|
||||
}
|
||||
|
||||
class Scratch {
|
||||
@@ -100,3 +102,25 @@ Future<Note?> getNextNote(String currentDate) async {
|
||||
// This handles the case where the `currentDate` might not be the absolute latest.
|
||||
return getLatestNote();
|
||||
}
|
||||
|
||||
// Search notes using full-text search
|
||||
Future<List<Note>> searchNotes(String query) async {
|
||||
if (query.isEmpty) {
|
||||
return [];
|
||||
}
|
||||
|
||||
// Call DB search function
|
||||
final List<Map<String, dynamic>> results = await DB.searchNotes(query);
|
||||
|
||||
// Convert results to Note objects
|
||||
return results
|
||||
.map(
|
||||
(result) => Note(
|
||||
date: result['date'] as String,
|
||||
content: result['content'] as String,
|
||||
snippet:
|
||||
result['snippet'] as String?, // Highlighted snippets from FTS
|
||||
),
|
||||
)
|
||||
.toList();
|
||||
}
|
||||
|
Reference in New Issue
Block a user