https://github.com/bakerface/dynamodb-snapshot-store
A snapshot store implementation on top of Amazon DynamoDB
https://github.com/bakerface/dynamodb-snapshot-store
Last synced: 10 months ago
JSON representation
A snapshot store implementation on top of Amazon DynamoDB
- Host: GitHub
- URL: https://github.com/bakerface/dynamodb-snapshot-store
- Owner: bakerface
- Created: 2017-02-06T10:59:30.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2017-04-22T15:19:55.000Z (about 9 years ago)
- Last Synced: 2025-06-18T03:09:28.207Z (11 months ago)
- Language: JavaScript
- Size: 3.91 KB
- Stars: 1
- Watchers: 1
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# dynamodb-snapshot-store
[](https://travis-ci.org/bakerface/dynamodb-snapshot-store)
[](https://npmjs.com/package/dynamodb-snapshot-store)
[](https://npmjs.com/package/dynamodb-snapshot-store)
[](https://codeclimate.com/github/bakerface/dynamodb-snapshot-store)
[](https://codeclimate.com/github/bakerface/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:
``` javascript
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.
``` javascript
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.
``` javascript
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
});
```