From 48f8f5d5c29634ce8f802b37434ae43c4fc84e31 Mon Sep 17 00:00:00 2001 From: Javier Cicchelli Date: Wed, 11 Feb 2026 17:44:44 +0100 Subject: [PATCH] Defined the Repository protocol in the app target. --- App/Sources/Protocols/Repository.swift | 28 ++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 App/Sources/Protocols/Repository.swift diff --git a/App/Sources/Protocols/Repository.swift b/App/Sources/Protocols/Repository.swift new file mode 100644 index 0000000..c1b97b3 --- /dev/null +++ b/App/Sources/Protocols/Repository.swift @@ -0,0 +1,28 @@ +import SwiftData + +/// A protocol defining the interface for a data repository. +/// +/// This protocol abstracts the underlying data persistence mechanism, allowing for +/// dependency injection and easier testing. Implementations handle the storage and +/// retrieval of model objects. +protocol Repository { + + /// Deletes a model object from the repository. + /// + /// This method removes the specified object from persistent storage. The deletion + /// is typically performed immediately, though the actual persistence may be deferred + /// until a save operation occurs depending on the implementation. + /// + /// - Parameter model: The model object to delete from the repository. + func delete(_ model: some PersistentModel) + + /// Inserts a new model object into the repository. + /// + /// This method adds a new object to persistent storage. The object is typically + /// tracked immediately, though the actual persistence may be deferred until a + /// save operation occurs depending on the implementation. + /// + /// - Parameter model: The model object to insert into the repository. + func insert(_ model: some PersistentModel) + +}