Settings and activity
5 results found
-
237 votesPriyatham Anisetty supported this idea ·
-
48 votesPriyatham Anisetty supported this idea ·
An error occurred while saving the comment -
146 votesPriyatham Anisetty supported this idea ·
-
26 votes
An error occurred while saving the comment Priyatham Anisetty commentedYes adding enum support will help us get rid of unnecessary tables to maintain enums. And this helps take advantage of postgress table automatic value validation
Priyatham Anisetty supported this idea · -
1 vote
An error occurred while saving the comment Priyatham Anisetty commentedRight now I have this struct
public struct InventoryItem: Decodable, Sendable ,Hashable, Equatable, Identifiable {
public var
id: UUIDpublic var
name: Stringpublic var
stockInHand: Doublepublic var
unit: Stringpublic var
lastUpdated: Timestamppublic var
costPerUnit: Doublepublic var
supplierName: String?public var
threshold: Double?
public var inventoryItemKey: InventoryItemKey {
return InventoryItemKey(
id: id
)
}
public func hash(into hasher: inout Hasher) {
hasher.combine(id)
}
public static func == (lhs: InventoryItem, rhs: InventoryItem) -> Bool {
return lhs.id == rhs.id
}
enum CodingKeys: String, CodingKey {
case id
case name
case stockInHand
case unit
case lastUpdated
case costPerUnit
case supplierName
case threshold
}public init(from decoder: any Decoder) throws {
var container = try decoder.container(keyedBy: CodingKeys.self)
let codecHelper = CodecHelper<CodingKeys>()
self.id = try codecHelper.decode(UUID.self, forKey: .id, container: &container)
self.name = try codecHelper.decode(String.self, forKey: .name, container: &container)
self.stockInHand = try codecHelper.decode(Double.self, forKey: .stockInHand, container: &container)
self.unit = try codecHelper.decode(String.self, forKey: .unit, container: &container)
self.lastUpdated = try codecHelper.decode(Timestamp.self, forKey: .lastUpdated, container: &container)
self.costPerUnit = try codecHelper.decode(Double.self, forKey: .costPerUnit, container: &container)
self.supplierName = try codecHelper.decode(String?.self, forKey: .supplierName, container: &container)
self.threshold = try codecHelper.decode(Double?.self, forKey: .threshold, container: &container)
}
}
public var
inventoryItems: [InventoryItem]}
public func ref(
storeId: String) -> QueryRefObservableObject<GetAllInventoryForStoreQuery.Data,GetAllInventoryForStoreQuery.Variables> {
var variables = GetAllInventoryForStoreQuery.Variables(storeId:storeId)
let ref = dataConnect.query(name: "getAllInventoryForStore", variables: variables, resultsDataType:GetAllInventoryForStoreQuery.Data.self, publisher: .observableObject)
return ref as! QueryRefObservableObject<GetAllInventoryForStoreQuery.Data,GetAllInventoryForStoreQuery.Variables>
}@MainActor
public func execute(
storeId: String) async throws -> OperationResult<GetAllInventoryForStoreQuery.Data> {
var variables = GetAllInventoryForStoreQuery.Variables(storeId:storeId)
let ref = dataConnect.query(name: "getAllInventoryForStore", variables: variables, resultsDataType:GetAllInventoryForStoreQuery.Data.self, publisher: .observableObject)
let refCast = ref as! QueryRefObservableObject<GetAllInventoryForStoreQuery.Data,GetAllInventoryForStoreQuery.Variables>
return try await refCast.execute()
}
}I can only init by creating a JSON object serialize it and then pass it to the decoder to decode. it makes me write unnecessary code in my Preview functions.
Priyatham Anisetty shared this idea ·
This would simplify our client side logic.