import { Injectable } from '@nestjs/common' ; import { EventPublisher } from '@nestjs/cqrs' ; import { EventStore } from '../../../core/eventstore/eventstore' ; import { Group } from '../../domain/model/group' ; import { GroupId } from '../../domain/model/group-id' ; import { Groups } from '../../domain/repository/groups' ; @ Injectable ( ) export class GroupEventStore implements Groups { constructor ( private readonly eventStore , private readonly publisher ) { } async get ( groupId ) { return this . eventStore . read ( Group , groupId . value ) ; } async find ( groupId ) { return this . eventStore . read ( Group , groupId . value ) ; } save ( group ) { group = this . publisher . mergeObjectContext ( group ) ; group . commit ( ) ; } nextIdentity ( ) { return GroupId . generate ( ) ; } }