Latest0.1.0
Homepagehttps://github.com/nikola-mladenovic/AwsSwiftDynamoDBsdk
LicenseApache License, Version 2.0
Platformsios 10.0, osx 10.10, tvos 9.0, watchos 2.2
DependenciesAwsSign
Authors

AwsDynamoDB – Swift

AwsDynamoDB is a Swift library that enables you to use Amazon DynamoDB with Swift. More details on this are available from the AWS DynamoDB docmentation.


AwsDynamoDBsdk


Swift 4.0


Platforms iOS | macOS | watchOS | tvOS | Linux


SPM compatible

This package builds with Swift Package Manager. Ensure you have installed and activated the latest Swift 4.0 tool chain.

Quick Start

To use AwsSns, modify the Package.swift file and add following dependency:

.package(url: "https://github.com/nikola-mladenovic/AwsSwiftDynamoDBsdk", .branch("master"))

Then import the AwsDynamoDB library into the swift source code:

import AwsDynamoDB

Usage

The current release supports following functionalities: Get Item, Put Item, Delete Item and Query. Library uses Codable to encode and decode items sent and recieved from DynamoDB.

To use library first initialize the AwsDynamoDB instance with your credentials and host. After that initialize AwsDynamoDBTable instance:

let dynamoDb = AwsDynamoDB(host: "https://dynamodb.us-west-2.amazonaws.com", accessKeyId: "OPKASPJPOAS23IOJS", secretAccessKey: "232(I(%$jnasoijaoiwj2919109233")
let testTable = dynamoDb.table(name: "test")

To get item from DynamoDB use the getItem method of the AwsDynamoDBTable instance:

testTable.getItem(key: (field: "id", value: "012345"), completion: { (success, item, error) in
    // Do some work
    ...
})

To put item from DynamoDB use the putItem method of the AwsDynamoDBTable instance:

struct Person: Codable {
    let id: String
    let name: String?
}

let person = Person(id: "012345", name: "Bill")

testTable.put(item: person, completion: { (success, error) in
    // Do some work
    ...
})

To delete item from DynamoDB use the deleteItem method of the AwsDynamoDBTable instance:

testTable.deleteItem(key: (field: "id", value: "012345"), completion: { (success, error) in
    // Do some work
    ...
})

To update item on DynamoDB use the update method of the AwsDynamoDBTable instance:

testTable.update(key: (field: "id", value: "012345"),
                 expressionAttributeValues: [":newBool" : true, ":incVal" : 3],
                 updateExpression: "SET bool=:newBool, num = num + :incVal",
                 completion: { (success, error) in
    // Do some work
    ...
})

To query items in DynamoDB use the query method of the AwsDynamoDBTable instance:

testTable.query(keyConditionExpression: "id = :ident", expressionAttributeValues: [":ident" : "012345"]) { (success, items, error) in
    // Do some work
    ...
}

To scan items in DynamoDB use the scan method of the AwsDynamoDBTable instance:

testTable.scan(expressionAttributeValues: [":ident" : "Test"], filterExpression: "id = :ident", limit: 1) { (success, items, error) in
// Do some work
...
}

Latest podspec

{
    "name": "AwsDynamoDBsdk",
    "version": "0.1.0",
    "summary": "Swift library providing easy access to common DynamoDB operations",
    "homepage": "https://github.com/nikola-mladenovic/AwsSwiftDynamoDBsdk",
    "license": {
        "type": "Apache License, Version 2.0",
        "file": "LICENSE"
    },
    "authors": {
        "Nikola Mladenovic": "[email protected]"
    },
    "source": {
        "git": "https://github.com/nikola-mladenovic/AwsSwiftDynamoDBsdk.git",
        "tag": "0.1.0"
    },
    "source_files": "Sources/AwsDynamoDB/*.swift",
    "swift_version": "4.0",
    "pod_target_xcconfig": {
        "SWIFT_VERSION": "4.0"
    },
    "platforms": {
        "ios": "10.0",
        "osx": "10.10",
        "tvos": "9.0",
        "watchos": "2.2"
    },
    "dependencies": {
        "AwsSign": [
            "~> 0.1"
        ]
    }
}

Pin It on Pinterest

Share This