import { Injectable } from '@nestjs/common' ; import { EventPublisher } from '@nestjs/cqrs' ; import { EventStore } from '../../../core/eventstore/eventstore' ; import { Members } from '../../domain/repository/members' ; import { Member } from '../../domain/model/member' ; import { MemberId } from '../../domain/model/member-id' ; @ Injectable ( ) export class MemberEventStore implements Members { constructor ( private readonly eventStore , private readonly publisher ) { } async get ( memberId ) { return this . eventStore . read ( Member , memberId . value ) ; } async find ( memberId ) { return this . eventStore . read ( Member , memberId . value ) ; } save ( member ) { member = this . publisher . mergeObjectContext ( member ) ; member . commit ( ) ; } }