ArkerLabs / event-sourcing-nestjs

NestJS module for implementing Event Sourcing
223 stars 47 forks source link

Type Problem in Eventstore #9

Closed FBurner closed 3 years ago

FBurner commented 3 years ago

I get eventstore is not a function in the Eventstore.ts

Nytyr commented 3 years ago

How are you using the EventStore? Do you inject it? Look at this example:

import { Injectable } from '@nestjs/common';
import { Hero } from '../models/hero.model';
import { EventStore } from 'event-sourcing-nestjs';

@Injectable()
export class HeroRepository {

  constructor(
    private readonly eventStore: EventStore,
  ) {}

  async findOneById(id: string): Promise<Hero> {
    const hero = new Hero(id);
    hero.loadFromHistory(await this.eventStore.getEvents('hero', id));
    return hero;
  }
}
FBurner commented 3 years ago

It was some internal problem with node-eventstore having no types for typescript my configuration couldnt handle it,

FBurner commented 3 years ago

I have rewritten the module to be configured for azuretables and others

FBurner commented 3 years ago

Seems snapshot creation was not implemented?

return new Promise<StorableEvent[]>(resolve => { this.eventstore.getFromSnapshot( this.getAgrregateId(aggregate, id), (err, snapshot, stream) => { // snapshot.data; // Snapshot resolve( stream.events.map(event => this.getStorableEventFromPayload(event.payload), ), ); }, ); });

There you try to get snap shots yet there is none created in the database and i dont see any call on createSnapshot

Nytyr commented 3 years ago

It's not implemented yet. I will open a new issue for this and any help will be gladly accepted 😁