Skip to content

Local SQLite storage layer (ILocalDataService) #122

@fboucher

Description

@fboucher

Parent PRD

#110

Depends on

#121 (needs updated Post/Note domain models with DateModified)

Summary

Implement the local offline storage layer for NoteBookmark.MauiApp using sqlite-net-pcl.

Interface

interface ILocalDataService
{
    Task<List<Post>> GetPostsAsync();
    Task<Post?> GetPostAsync(string id);
    Task SavePostAsync(Post post);
    Task SavePostsAsync(IEnumerable<Post> posts);
    Task<List<Note>> GetNotesAsync();
    Task<Note?> GetNoteAsync(string rowKey);
    Task SaveNoteAsync(Note note);
    Task<List<Post>> GetPendingSyncPostsAsync();
    Task<List<Note>> GetPendingSyncNotesAsync();
    Task MarkSyncedAsync(string id, bool isPost);
}

Local schema (mirrors domain models + sync fields)

  • DateModified (DateTime UTC)
  • IsPendingSync (bool) — true when written offline
  • IsDeleted (bool) — soft delete flag

Database lifecycle

  • Initialized and migrated on app startup
  • LastSyncTimestamp stored in MAUI Preferences

Tests

  • Use in-memory or temp-file SQLite DB
  • Test: save a post/note → retrieve it → update it → soft-delete it → query pending sync records
  • Follow existing AzureStorageTestFixture pattern in NoteBookmark.Api.Tests

Acceptance Criteria

  • ILocalDataService interface defined
  • LocalDataService implementation with sqlite-net-pcl
  • Schema includes DateModified, IsPendingSync, IsDeleted
  • DB initialized on startup
  • Integration tests pass

Offline stories from PRD

User stories 2, 3, 4, 5, 6

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    Status

    Backlog

    Status

    No status

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions