in app/com/gu/floodgate/DynamoDBTable.scala [47:75]
def getItems(id: String)(implicit ec: ExecutionContext): Future[List[T]] =
scanamoAsync.exec(table.descending.query(keyName -> id)).map(reportErrors)
def getItemsWithFilter(id: String, filterKeyName: String, filterValue: String)(
implicit ec: ExecutionContext
): Future[List[T]] =
scanamoAsync
.exec(table.descending.filter(Condition(filterKeyName -> filterValue)).query(keyName -> id))
.map(reportErrors _)
def getLatestItem(id: String, filterKeyName: String, filterValue: String)(
implicit ec: ExecutionContext
): Future[Option[T]] =
scanamoAsync
.exec(
table.descending.limit(1).filter(Condition(filterKeyName -> filterValue)).query(keyName -> id)
)
.map(reportErrors _)
.map(_.headOption)
def saveItem(t: T): Option[Either[DynamoReadError, T]] = scanamoSync.exec(table.put(t))
def deleteItem(hashKey: String): Unit = scanamoSync.exec(table.delete(keyName -> hashKey))
def deleteItem(hashKey: String, sortKey: String): Unit = {
maybeSortKeyName map { sortKeyName =>
scanamoSync.exec(table.delete(keyName-> hashKey and sortKeyName -> sortKey))
}
}