Skip to content

Commit

Permalink
Merge pull request #68 from meteor-space/feature/improve-projection-r…
Browse files Browse the repository at this point in the history
…ebuilder

Do not throw errors if there is no data to insert after rebuilding projected collection
  • Loading branch information
DominikGuzei committed Mar 9, 2016
2 parents 712d312 + 75c129c commit 196bbed
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
Changelog
=========

## newVersion
### Changes to projection rebuilder
- `Space.eventSourcing.ProjectionRebuilder ` is no longer throwing an error if there is no data to insert into collection after rebuilding is done. Info message is now logged instead.

## 3.0.0

### New Features
Expand Down
7 changes: 6 additions & 1 deletion source/server/infrastructure/projection-rebuilder.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ class Space.eventSourcing.ProjectionRebuilder extends Space.Object

dependencies: {
commitStore: 'Space.eventSourcing.CommitStore'
configuration: 'configuration'
injector: 'Injector'
mongo: 'Mongo'
log: 'log'
}

rebuild: (projections, options) ->
Expand Down Expand Up @@ -42,7 +44,7 @@ class Space.eventSourcing.ProjectionRebuilder extends Space.Object
if inMemoryData.length
realCollection.batchInsert inMemoryData
else
throw new Error "No data to insert after replaying events for #{collectionId}"
@log.info(@_logMsg("No data to insert after replaying events for #{collectionId}"))
# Restore original collections
@injector.override(collectionId).to realCollection

Expand All @@ -54,3 +56,6 @@ class Space.eventSourcing.ProjectionRebuilder extends Space.Object
for property, id of projection.collections
collectionIds.push(id) if projection[property]
return collectionIds

_logMsg: (message) ->
"#{@configuration.appId}: #{this}: #{message}"

0 comments on commit 196bbed

Please sign in to comment.