feat: Initial purchase order views, login seems to be broken though.
This commit is contained in:
@@ -34,6 +34,11 @@ public extension DatabaseClient.VendorBranches {
|
||||
}
|
||||
|
||||
return try await query.all().map { try $0.toDTO() }
|
||||
} fetchAllWithDetail: {
|
||||
try await VendorBranchModel.query(on: db)
|
||||
.with(\.$vendor)
|
||||
.all()
|
||||
.map { try $0.toDetail() }
|
||||
} get: { id in
|
||||
try await VendorBranchModel.find(id, on: db).map { try $0.toDTO() }
|
||||
} update: { id, updates in
|
||||
@@ -147,6 +152,16 @@ final class VendorBranchModel: Model, @unchecked Sendable {
|
||||
)
|
||||
}
|
||||
|
||||
func toDetail() throws -> VendorBranch.Detail {
|
||||
try .init(
|
||||
id: requireID(),
|
||||
name: name,
|
||||
vendor: vendor.toDTO(),
|
||||
createdAt: createdAt,
|
||||
updatedAt: updatedAt
|
||||
)
|
||||
}
|
||||
|
||||
func applyUpdates(_ updates: VendorBranch.Update) throws {
|
||||
try updates.validate()
|
||||
if let name = updates.name {
|
||||
|
||||
Reference in New Issue
Block a user