Aggregate snapshots allow you to store the state of aggregate instances manually and/or at given version intervals. This allows for more efficient loading of aggregate instances with a large number of commits.
Defining a SnapshotStore import {AwsSnapshotStore} from '@ddes/aws-store' export default new AwsEventStore({ bucketName: `ddes-snapshots` , keyPrefix: 'snapshots/' , manageBucket: true , })
Configure Aggregate class to use snapshots class MyAggregate extends Aggregate { static snapshotStore = mySnapshotStore static snapshotFrequency = 1000 }
Manually write snapshot await myinstance.writeSnapshot()
Skipping snapshotting when committing myinstance.commit(myEvents, {skipSnapshot: true })
Using local S3 Running docker container docker run --rm -d --name s3 -p 5000:5000 skalar/fakes3 \ s3rver --hostname 0.0.0.0 --port 5000 --directory /tmp/s3 --silent docker kill s3
Configuration import {AwsSnapshotStore} from '@ddes/aws-store' export default new AwsSnapshotStore({ tableName: `ddes-main` , dynamodbClientConfiguration: { endpoint: 'http://localhost:8000' , region: 'us-east-1' , accessKeyId: 'test' , secretAccessKey: 'test' , }, })
See API docs for details.