-
Notifications
You must be signed in to change notification settings - Fork 1
/
backup.ts
67 lines (65 loc) · 1.87 KB
/
backup.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
//region bankaccountaggregate
// @CommandHandler
// async handle(command: CreateBankAccountCommand) {
// const event = new BankAccountCreatedEvent(command.aggregateId);
// await this.apply(event);
// }
//
// @CommandHandler
// async handleWithdrawal(command: WithdrawalCommand) {
// if (this.isBalanceSufficient(command.amount)) {
// await this.apply(new WithdrawalEvent(command.aggregateId, command.amount));
// } else {
// throw new Error('Balance is insufficient');
// }
// }
//
// @CommandHandler
// async handleDeposit(command: DepositCommand) {
// await this.apply(new DepositEvent(command.aggregateId, command.amount));
// }
//
// @EventHandler
// async on(_event: BankAccountCreatedEvent) {
// this.balance = 0;
// }
//
// @EventHandler
// async onDeposit(event: DepositEvent) {
// this.balance += event.amount;
// }
//
// @EventHandler
// async onWithdrawal(event: WithdrawalEvent) {
// this.balance -= event.amount;
// }
//endregion
//region bankaccountprojectionprocessor
// async handleCreatedEvent(event: BankAccountCreatedEvent) {
// await this.save({
// aggregateId: event.aggregateId,
// balance: 0,
// });
// }
//
// async handleDepositEvent(event: DepositEvent) {
// const bankAccountProjection = await this.fetch(event.aggregateId);
// bankAccountProjection.balance += event.amount;
// await this.save(bankAccountProjection);
// }
//
// async handleWithdrawalEvent(event: WithdrawalEvent) {
// const bankAccountProjection = await this.fetch(event.aggregateId);
// bankAccountProjection.balance -= event.amount;
// await this.save(bankAccountProjection);
// }
//endregion
//region emailprocessor
// async handleCreatedEvent(event: BankAccountCreatedEvent) {
// console.log(`Sending email to ${event.aggregateId}`);
// }
//
// async handleDepositEvent(_event: DepositEvent) {
// console.log('Sending mail about deposit');
// }
//endregion