This repository has been archived on 2026-02-12. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
swift-duct-calc/Sources/DatabaseClient/Interface.swift

36 lines
797 B
Swift

import Dependencies
import DependenciesMacros
import FluentKit
import ManualDCore
extension DependencyValues {
public var database: DatabaseClient {
get { self[DatabaseClient.self] }
set { self[DatabaseClient.self] = newValue }
}
}
@DependencyClient
public struct DatabaseClient: Sendable {
public var migrations: Migrations
public var projects: Projects
}
extension DatabaseClient {
@DependencyClient
public struct Migrations: Sendable {
public var run: @Sendable () async throws -> [any AsyncMigration]
}
}
extension DatabaseClient: TestDependencyKey {
public static let testValue: DatabaseClient = Self(
migrations: .testValue,
projects: .testValue
)
}
extension DatabaseClient.Migrations: TestDependencyKey {
public static let testValue = Self()
}