Last active
June 24, 2017 00:18
-
-
Save gistlyn/d36339c55be6a43942a60c1eaf687bfd to your computer and use it in GitHub Desktop.
PocoDynamo Todo Demo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using Amazon; | |
using Amazon.DynamoDBv2; | |
using ServiceStack; | |
using ServiceStack.Text; | |
using ServiceStack.Aws.DynamoDb; | |
using ServiceStack.DataAnnotations; | |
var awsDb = new AmazonDynamoDBClient("keyId","key",new AmazonDynamoDBConfig { ServiceURL="http://localhost:8000"}); | |
var db = new PocoDynamo(awsDb); | |
public class Todo | |
{ | |
[AutoIncrement] | |
public long Id { get; set; } | |
public string Content { get; set; } | |
public int Order { get; set; } | |
public bool Done { get; set; } | |
} | |
db.RegisterTable<Todo>(); | |
db.DeleteTable<Todo>(); // Delete existing Todo Table (if any) | |
db.InitSchema(); // Creates Todo DynamoDB Table | |
var newTodo = new Todo { | |
Content = "Learn PocoDynamo", | |
Order = 1 | |
}; | |
db.PutItem(newTodo); | |
var savedTodo = db.GetItem<Todo>(newTodo.Id); | |
"Saved Todo: {0}".Print(savedTodo.Dump()); | |
savedTodo.Done = true; | |
db.PutItem(savedTodo); | |
var updatedTodo = db.GetItem<Todo>(newTodo.Id); | |
"Updated Todo: {0}".Print(updatedTodo.Dump()); | |
db.DeleteItem<Todo>(newTodo.Id); | |
var remainingTodos = db.GetAll<Todo>(); | |
"No more Todos: {0}".Print(remainingTodos.Dump()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<packages> | |
<package id="AWSSDK.Core" version="3.3.10.2" targetFramework="net45" /> | |
<package id="AWSSDK.DynamoDBv2" version="3.3.4.3" targetFramework="net45" /> | |
<package id="AWSSDK.S3" version="3.3.5.10" targetFramework="net45" /> | |
<package id="AWSSDK.SQS" version="3.3.1.10" targetFramework="net45" /> | |
<package id="ServiceStack.Text" version="4.5.12" targetFramework="net45" /> | |
<package id="ServiceStack.Client" version="4.5.12" targetFramework="net45" /> | |
<package id="ServiceStack.Interfaces" version="4.5.12" targetFramework="net45" /> | |
<package id="ServiceStack.Common" version="4.5.12" targetFramework="net45" /> | |
<package id="ServiceStack" version="4.5.12" targetFramework="net45" /> | |
<package id="ServiceStack.Aws" version="4.5.12" targetFramework="net45" /> | |
</packages> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment