Amazon的DynamoDB差异数据同步:dynamo-sync

jopen 7年前

dynamo-sync

Amazon的DynamoDB差异数据同步。
Differential data synchronization for Amazon's DynamoDB

Example

var aws = require("aws-sdk")  var Table = require("dynamo-sync").Table    var db = new aws.DynamoDB  var table = Table(db, "myTable")    var data = [    {id: 1, name: "Jed"},    {id: 2, name: "Michael"},    {id: 3, name: "Martin"}  ]    table.push(data, function(err){ if (err) throw err })

API

table = new Table(db, name)

Creates a new table, where db is a DynamoDB instance from the aws-sdk library, and name is the name of the table.

table#pull(local, cb)

Fills the local array with the contents of the remote table.

table#push(local, cb)

Diffs the local array with the remote table, and uses the BatchWriteItem API to issue writes only for keys that have changed. Local keys not present remotely will be put, and remote keys not present locally will be deleted.


项目主页:http://www.open-open.com/lib/view/home/1417188282237