即使对象存在,DynamoDB 查询每次都返回 nil

DynamoDB query returning nil every time even when the object exists

我有一个查询 returns 每次我 运行 它都是零,尽管有一些项目带有我传递的密钥。

我将我的表达式设置为:

queryExpression.keyConditionExpression = "#uID = :uidValue"

// in my model class
var uID: String?

uidValue 是我要与 "uID" 进行比较的值。

我已经通读了 AWS 的相关文档,但没有找到任何有用的信息。

//implementation of query
let dynamoDbObjectMapper = AWSDynamoDBObjectMapper.default()


dynamoDbObjectMapper.query(GameTracker.self, expression: queryExpression) { (output: AWSDynamoDBPaginatedOutput?, error: Error?) in
  if(output == nil){
    //create new user here, this keeps getting run each time
  }else{
    //user found, run other logic
  }
}

我 运行宁 uID 我知道存在于我的 table 中,但它每次都返回 nil 并抛出错误。不幸的是,关于此的 AWS 文档并没有提供很多关于我所发现的可能出错的新见解。

我通过将 uID 指定为我的分区键并仅通过哈希键搜索来解决这个问题。