【发布时间】:2020-08-08 16:47:23
【问题描述】:
在我的应用程序中,我试图检查是否有 2 个用户已经在我的 AWS DynamoDB 表中创建了对话,如果没有,将创建用户之间的对话。我使用列表查询函数来检查是否创建了 currentUserSub 和 recieverUserSub 的数组,但我收到一个错误提示
Binary operator '==' cannot be applied to operands of type 'Conversation.CodingKeys' and '[String]'
Conversations 在其表中具有名为 members 的字段,该字段是字符串的数组值。
这是我的代码:
let conversations = Conversation.keys
let predicate = conversations.members == [currentUserSub, recieverUserSub] // this is where I get the error
_ = Amplify.API.query(request: .list(Conversation.self, where: predicate)) { event in
switch event {
case .success(let result):
switch result {
case .success(let convo):
print("Successfully retrieved the convo: \(convo)")
case .failure(let error):
print("Got failed result with \(error.errorDescription)")
}
case .failure(let error):
print("Got failed event with error \(error)")
}
}
我该如何解决这个问题?
我从放大文档https://docs.amplify.aws/lib/graphqlapi/query-data/q/platform/ios#list-query中引用了这个函数
【问题讨论】:
标签: swift aws-amplify