dynamodb-snapshot-store
v1.0.1
Published
A snapshot store implementation on top of Amazon DynamoDB
Downloads
4
Readme
dynamodb-snapshot-store
This package provides a simple snapshot store implementation on top of Amazon DynamoDB. This is meant to be a general purpose package, and makes no assumptions about the structure or type of your states. The states are serialized to JSON when stored, and deserialized automatically when fetching. For a few examples, view the samples below:
var SnapshotStore = require('dynamodb-snapshot-store');
var snapshotStore = new SnapshotStore({
region: 'us-east-1',
accessKeyId: 'access-key-id',
secretAccessKey: 'secret-access-key',
tableName: 'snapshots'
});
snapshotStore.store(snapshot)
An atomic write of a snapshot to the store.
var snapshot = {
snapshotId: '00000000-0000-0000-0000-000000000000',
state: {
foo: 'bar'
}
};
snapshotStore.store(snapshot)
.then(function () {
// the snapshot was stored
})
.catch(function (err) {
// something went wrong
});
});
snapshotStore.fetch(options)
Fetches the aggregate state from the snapshot store.
var options = {
snapshotId: '00000000-0000-0000-0000-000000000000'
};
snapshotStore.fetch(options)
.then(function (snapshot) {
// =>
{
snapshotId: '00000000-0000-0000-0000-000000000000',
createdAt: 946684800000,
state: {
foo: 'bar'
}
}
})
.catch(function (err) {
// something went wrong
});