feat working on vendor views.

This commit is contained in:
2025-01-16 08:02:13 -05:00
parent 6f2e87e886
commit d4a8444700
8 changed files with 239 additions and 132 deletions

View File

@@ -9,25 +9,35 @@ public extension DatabaseClient {
public var create: @Sendable (Vendor.Create) async throws -> Vendor
public var delete: @Sendable (Vendor.ID) async throws -> Void
public var fetchAll: @Sendable (FetchRequest) async throws -> [Vendor]
public var get: @Sendable (Vendor.ID, GetRequest) async throws -> Vendor?
public var update: @Sendable (Vendor.ID, Vendor.Update) async throws -> Vendor
public var get: @Sendable (Vendor.ID, GetRequest?) async throws -> Vendor?
public var update: @Sendable (Vendor.ID, Vendor.Update, GetRequest?) async throws -> Vendor
public enum FetchRequest {
public enum FetchRequest: Sendable {
case all
case withBranches
}
public enum GetRequest {
case all
public enum GetRequest: Sendable {
case withBranches
}
@Sendable
public func fetchAll() async throws -> [Vendor] {
try await fetchAll(.all)
}
@Sendable
public func get(_ id: Vendor.ID) async throws -> Vendor? {
try await get(id, .all)
try await get(id, nil)
}
@Sendable
public func update(
_ id: Vendor.ID,
with updates: Vendor.Update,
returnWithBranches: Bool = false
) async throws -> Vendor {
try await update(id, updates, returnWithBranches ? GetRequest.withBranches : nil)
}
}
}