feat working on vendor views.
This commit is contained in:
@@ -37,13 +37,20 @@ public extension DatabaseClient.Vendors {
|
||||
query = query.with(\.$branches)
|
||||
}
|
||||
return try await query.first().map { try $0.toDTO(includeBranches: withBranches) }
|
||||
} update: { id, updates in
|
||||
} update: { id, updates, withBranches in
|
||||
guard let model = try await VendorModel.find(id, on: db) else {
|
||||
throw NotFoundError()
|
||||
}
|
||||
try model.applyUpdates(updates)
|
||||
try await model.save(on: db)
|
||||
return try model.toDTO()
|
||||
if withBranches != .withBranches {
|
||||
return try model.toDTO()
|
||||
}
|
||||
return try await VendorModel.query(on: db)
|
||||
.filter(\.$id == id)
|
||||
.with(\.$branches)
|
||||
.first()!
|
||||
.toDTO()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user