Files
vapor-po/Sources/DatabaseClient/VendorBranches.swift

35 lines
1.2 KiB
Swift

import Dependencies
import DependenciesMacros
import SharedModels
import Vapor
public extension DatabaseClient {
@DependencyClient
struct VendorBranches: Sendable {
public var create: @Sendable (VendorBranch.Create) async throws -> VendorBranch
public var delete: @Sendable (VendorBranch.ID) async throws -> Void
public var fetchAll: @Sendable (FetchRequest) async throws -> [VendorBranch]
public var fetchAllWithDetail: @Sendable () async throws -> [VendorBranch.Detail]
public var get: @Sendable (VendorBranch.ID) async throws -> VendorBranch?
public var update: @Sendable (VendorBranch.ID, VendorBranch.Update) async throws -> VendorBranch
public enum FetchRequest: Equatable {
case all
case `for`(vendorID: Vendor.ID)
}
public func fetchAll() async throws -> [VendorBranch] {
try await fetchAll(.all)
}
}
}
extension VendorBranch: Content {}
extension VendorBranch.Create: Content {}
extension VendorBranch.Update: Content {}
extension DatabaseClient.VendorBranches.FetchRequest: Content {}
extension DatabaseClient.VendorBranches: TestDependencyKey {
public static let testValue: DatabaseClient.VendorBranches = Self()
}