feat: Adds script to generate database seeded values and removes old mock storage.
This commit is contained in:
@@ -42,3 +42,41 @@ public extension VendorBranch {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#if DEBUG
|
||||
// public extension VendorBranch {
|
||||
//
|
||||
// static func generateMocks(countPerVendor: Int = 3, vendors: [Vendor]) -> [Self] {
|
||||
// @Dependency(\.date.now) var now
|
||||
// @Dependency(\.uuid) var uuid
|
||||
//
|
||||
// var output = [Self]()
|
||||
//
|
||||
// for vendor in vendors {
|
||||
// for _ in 0 ... countPerVendor {
|
||||
// output.append(.init(
|
||||
// id: uuid(),
|
||||
// name: RandomNames.cityNames.randomElement()!,
|
||||
// vendorID: vendor.id,
|
||||
// createdAt: now,
|
||||
// updatedAt: now
|
||||
// ))
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// return output
|
||||
// }
|
||||
// }
|
||||
|
||||
public extension VendorBranch.Create {
|
||||
|
||||
static func generateMocks(countPerVendor: Int = 3, vendors: [Vendor]) -> [Self] {
|
||||
return vendors.reduce(into: [Self]()) { output, vendor in
|
||||
output = (0 ... countPerVendor).reduce(into: output) { array, _ in
|
||||
array.append(.init(name: RandomNames.cityNames.randomElement()!, vendorID: vendor.id))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user