Flatten the DynamoOutput so we use DynamoValue directly
This commit is contained in:
parent
66deb3fa0f
commit
1100512847
|
@ -11,7 +11,7 @@ import DatabaseKit
|
|||
public final class DynamoDatabase: Database {
|
||||
public typealias Connection = DynamoConnection
|
||||
public typealias Query = DynamoQuery
|
||||
public typealias Output = DynamoOutput
|
||||
public typealias Output = DynamoValue
|
||||
|
||||
private let config: DynamoConfiguration
|
||||
|
||||
|
|
|
@ -64,19 +64,19 @@ extension DynamoConnection: DatabaseQueryable {
|
|||
case .get:
|
||||
let inputItem = DynamoDB.GetItemInput(key: query.key.encodedKey, tableName: query.table)
|
||||
let _ = try self.handle.getItem(inputItem).map { output in
|
||||
try handler(DynamoOutput(result: output.item))
|
||||
try handler(Output(attributes: output.item))
|
||||
promise.succeed()
|
||||
}
|
||||
case .set:
|
||||
let input = DynamoDB.PutItemInput(returnConsumedCapacity: nil, conditionalOperator: nil, conditionExpression: nil, tableName: query.table, expressionAttributeValues: nil, item: query.key.encodedKey, expected: nil, returnValues: nil, returnItemCollectionMetrics: nil, expressionAttributeNames: nil)
|
||||
let _ = try self.handle.putItem(input).map { output in
|
||||
try handler(DynamoOutput(result: output.attributes))
|
||||
try handler(Output(attributes: output.attributes))
|
||||
promise.succeed()
|
||||
}
|
||||
case .delete:
|
||||
let input = DynamoDB.DeleteItemInput(key: query.key.encodedKey, tableName: query.table)
|
||||
let _ = try self.handle.deleteItem(input).map { output in
|
||||
try handler(DynamoOutput(result: output.attributes))
|
||||
try handler(DynamoValue(attributes: output.attributes))
|
||||
promise.succeed()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,16 +0,0 @@
|
|||
//
|
||||
// DynamoOutput.swift
|
||||
// FluentDynamoDB
|
||||
//
|
||||
// Created by Joe Smith on 4/12/19.
|
||||
//
|
||||
|
||||
import DynamoDB
|
||||
|
||||
public struct DynamoOutput {
|
||||
public let result: DynamoValue?
|
||||
|
||||
public init(result: [String: DynamoDB.AttributeValue]?) {
|
||||
self.result = DynamoValue(attributes: result)
|
||||
}
|
||||
}
|
|
@ -1,13 +0,0 @@
|
|||
//
|
||||
// DynamoModel.swift
|
||||
// fluent-dynamodb-driver
|
||||
//
|
||||
// Created by Joe Smith on 4/10/19.
|
||||
//
|
||||
|
||||
import Fluent
|
||||
|
||||
/// A Dynamo database model.
|
||||
/// See `Fluent.Model`.
|
||||
/*public protocol DynamoModel: Model where Self.Database == DynamoDatabase {
|
||||
}*/
|
Loading…
Reference in New Issue