30 lines
822 B
Swift
30 lines
822 B
Swift
import Dependencies
|
|
import DependenciesMacros
|
|
import SharedModels
|
|
|
|
public extension DatabaseClient {
|
|
|
|
@DependencyClient
|
|
struct Employees: Sendable {
|
|
public var create: @Sendable (Employee.Create) async throws -> Employee
|
|
public var delete: @Sendable (Employee.ID) async throws -> Void
|
|
public var fetchAll: @Sendable (FetchRequest) async throws -> [Employee]
|
|
public var get: @Sendable (Employee.ID) async throws -> Employee?
|
|
public var update: @Sendable (Employee.ID, Employee.Update) async throws -> Employee
|
|
|
|
public func fetchAll() async throws -> [Employee] {
|
|
try await fetchAll(.all)
|
|
}
|
|
|
|
public enum FetchRequest {
|
|
case active
|
|
case all
|
|
case inactive
|
|
}
|
|
}
|
|
}
|
|
|
|
extension DatabaseClient.Employees: TestDependencyKey {
|
|
public static let testValue = Self()
|
|
}
|