Short tutorial (https://www.youtube.com/watch?v=10eev5FyduQ&t=6s)
Demo link (http://dynamosync-demo.zhaosiyang.com:8080)
Demo repo (https://github.com/zhaosiyang/DynamoSync-demo)
Dynamosync is a package that allows developer to bind DynamoDB with frontend variable in Angular so that the frontend variable reflects the immediate state of DynamoDB tables. (You can think of it as a light "Firebase" of DynamoDB)
Currently DynamoSync only support stack of Angular2 + NodeJS
- dynamosync-server
- ng-dynamosync
- forwarder
In the server side (NodeJS):
npm install dynamosync-server --save
In the client side (Angular2):
npm install ng-dynamosync --save
Also, you will need to create AWS lambda from the zip file, for downloading the zip file, you can either go to (https://github.com/zhaosiyang/DynamoSync/tree/master/dynamosync-forwarder) to download the zip file or just download using:
npm install forwarder
and get the zip file from your node_modules
Step0: Setting up AWS credentials
- TABLE_NAME (Your DynamoDB table name)
- URL (Your NodeJS server URL, e.g. 12.345.6.789:8080)
step1.3: Connect DynamoDB table with the lambda function by setting a trigger in AWS console so that any updates on the specified table will trigger the lambda function you have just set.
import {DynamoSync} from 'dynamosync-server';
DynamoSync.configApp(app);
DynamoSync.configIO(server,['arn:aws:dynamodb:us-west-2:**********:table/ShoppingList']);
Please note that the second parameter is an array of string, each string is the ARN of the DynamoDB table you want to use. (order does NOT matter)
import {NgDynamoSync} from "ng-dynamosync";
const subscription1 = new NgDynamoSync('ShoppingList',this.serverDomain).bindToListModel(this.shoppingItems);
}
By doing the above steps, you have successfully binded the Angular variable this.shoppingItems to the documents of the table ShoppingList in DynamoDB
- bind list variable
l
to dynamoDB table "Games"this.subscription = new NgDynamoSync('Games','1.23.456.789:8080').bindToListModel(this.shoppingItems);
- bind an variable
t
to dynamoDB single object in table "Games", with key to be "gameId" and value to be "456".this.subscription = new NgDynamoSync('Games', '1.23.456.789:8080').getObjectStream('gameId', '456').subscribe(game => this.t = game)
- bind list variable
chats
to dynamoDB table "Chats", only allow INSERT event (without previous chats initialized).this.sub2 = new NgDynamoSync('Chat', '1.23.456.789:8080').onlyAllowEventNames(EventName.INSERT).bindToListModel(this.chats);
notes:
'1.23.456.789:8080' should be replaced by the node server url
don't forget to unsubscribe the subscription
when your view get destroyed