我将客户个人资料及其个人交易存储在DynamoDB中。我还创建了一个表来存储这些交易的汇总。 (示例:如果某个客户多次访问该市场,那么该表除了记录每个客户所花费的总金额的表外,还将有很多针对该客户的单独交易。)但是,在创建该表时,我不知道如何更新。
这是我用来进行单独的发行/交易的代码。
@IBAction func makeDistributionButtonPressed(_ sender: UIButton) {
let distribution = Distribution(firstInitial: firstInitialTextField.text ?? "None", lastInitial: lastInitialTextField.text ?? "None", EBTCustomerNumber: EBTCustomerNumberTextField.text ?? "None", matchingMoneyAvailable: Int(availableMoneyForMatchingTextField.text!) ?? 0, amountCustomerRequests: Int(amountCustomerRequestTextField.text!) ?? 0, totalMatchDistributed: Int(matchMoneyOwedCustomerTextField.text!) ?? 0, totalEBTDistributed: Int(EBTOwedCustomerTextField.text!) ?? 0, totalOwedMarket: Int(amountOwedMarketTextField.text!) ?? 0, totalSpent: totalSpent)
CreateDistribution().createDailyDistribution(input: distribution)
self.updateAggregate()
showMessage(messageToDisplay: "Distribution made!")
}
这是我尝试用来执行更新的内容
func updateAggregate(){
appSyncClient?.fetch(query: ListCustomerRegistrationsQuery(), cachePolicy: .returnCacheDataAndFetch) {(result, error) in
if error != nil {
print(error?.localizedDescription ?? "")
return
}
result?.data?.listCustomerRegistrations?.items!.forEach {
if $0?.firstInitial == self.firstInitialTextField.text?.uppercased() && $0?.lastInitial == self.lastInitialTextField.text?.uppercased() && $0?.needIndicatorId == self.EBTCustomerNumberTextField.text {
print(($0?.marketName)!)
let updateEBTTotal = Aggregate(firstInitial: self.firstInitialTextField.text ?? "None", lastInitial: self.lastInitialTextField.text ?? "None", EBTCustomerNumber: self.EBTOwedCustomerTextField.text ?? "None", totalMatchDistributed: Int(self.matchMoneyOwedCustomerTextField.text!) ?? 0, totalEBTDistributed: Int(self.EBTOwedCustomerTextField.text!) ?? 0)
CreateDistribution().updateAggregateTransactions(input: updateEBTTotal)
}
else{
print("Could not update the information.")
}
}
}
}
我正在尝试更新totalMatchDistributed
和totalEBTDistributed
字段。