feat working on vendor views.
This commit is contained in:
@@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user