Skip to content

Commit

Permalink
Make updates to allow passing Ids with aggregate create commands
Browse files Browse the repository at this point in the history
  • Loading branch information
brettmorien committed Jul 11, 2017
1 parent d870dcd commit 2194163
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 3 deletions.
1 change: 1 addition & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ exports.Event = require('./lib/event');
exports.Identity = require('./lib/identity');
exports.BasicHandler = require('./lib/basicCommandHandler');
exports.CommandHandler = require('./lib/commandHandler');
exports.CreateAggregateCommandHandler = require('./lib/createAggregateCommandHandler');
exports.AggregateCommandHandler = require('./lib/aggregateCommandHandler');
exports.Repository = require('./lib/repository');
exports.ValidationError = require('./lib/validationError');
Expand Down
2 changes: 2 additions & 0 deletions lib/createAggregateCommandHandler.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/repository.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/createAggregateCommandHandler.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import AggregateCommandHandler from './aggregateCommandHandler';

export default class CreateAggregateCommandHandler extends AggregateCommandHandler {
isCreateHandler = true;
}
3 changes: 1 addition & 2 deletions src/repository.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,12 @@ export default class Repository {
get = async(aggregateId) => {
let events = await (await this.getStore()).getEvents(aggregateId);
if (!events.length) {
console.log(`Aggregate ${aggregateId} not found`);
return null;
}
return new this.Ctor(aggregateId, events);
}

create = () => new this.Ctor(uuidV4());
create = id => new this.Ctor(id || uuidV4());

record = async events => {
let store = await this.getStore();
Expand Down

0 comments on commit 2194163

Please sign in to comment.