Permalink
Browse files

#11

  • Loading branch information...
adrai committed Jul 11, 2013
1 parent a2f35e0 commit 4c075caaa1e892c3784e976dd21d67a60a20b3eb
Showing with 13 additions and 3 deletions.
  1. +4 −0 README.md
  2. +3 −1 lib/bases/commandHandlerBase.js
  3. +1 −1 licence
  4. +1 −1 package.json
  5. +4 −0 test/integration/aggregates/dummyAggregate.js
View
@@ -76,6 +76,10 @@ See [tests](https://github.com/adrai/node-cqrs-domain/tree/master/test) for deta
# Release Notes
+## v0.4.1
+
+- added optional snapshotThreshold on aggregate
+
## v0.4.0
- asynchronous api for saga
@@ -88,7 +88,9 @@ CommandHandler.prototype = {
if (!err) {
stream.commit(function(err) {
// Check if snapshotting is needed.
- if (stream.events.length >= self.options.snapshotThreshold) {
+ if (aggregate.snapshotThreshold && ((_.isFunction(aggregate.snapshotThreshold) && stream.events.length >= aggregate.snapshotThreshold()) ||
+ (_.isNumber(aggregate.snapshotThreshold) && stream.events.length >= aggregate.snapshotThreshold)) ||
+ stream.events.length >= self.options.snapshotThreshold) {
self.eventStore.createSnapshot(stream.streamId, stream.currentRevision(), aggregate.toJSON());
}
});
View
@@ -1,4 +1,4 @@
-Copyright (c) 2012 Adriano Raiano
+Copyright (c) 2013 Adriano Raiano
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
View
@@ -1,7 +1,7 @@
{
"author": "adrai",
"name": "cqrs-domain",
- "version": "0.4.0",
+ "version": "0.4.1",
"private": false,
"main": "index.js",
"engines": {
@@ -2,6 +2,10 @@ var base = require('../../../index').aggregateBase;
module.exports = base.extend({
+ // snapshotThreshold: 20,
+ // or
+ // snapshotThreshold: function() { return 12 + 10; },
+
changeDummy: function(data, callback) {
this.apply(this.toEvent('dummyChanged', data));

0 comments on commit 4c075ca

Please sign in to comment.