juicycleff / nestjs-event-store

NestJS CQRS module for EventStore.org. It requires @nestjs/cqrs
https://xraph.com
MIT License
199 stars 29 forks source link

how to access service in IAdapterStore? #40

Closed peterDijk closed 2 years ago

peterDijk commented 2 years ago

How is it possible to write/ read to/from database in the AdapterStore? I have a service with methods for reading from and writing the my database to read the last checkpoints position, but I don't have access to that in the Module setup, static method

static register(): DynamicModule {
    return {
      module: GamesModule,
      imports: [
        CqrsModule,
        EventStoreModule.registerFeatureAsync({
          type: 'event-store',
          useFactory: async (...args) => {
            return {
              featureStreamName: '$ce-game',
              type: 'event-store',
              subscriptions: [
                {
                  type: EventStoreSubscriptionType.CatchUp,
                  stream: '$ce-game',
                },
              ],
              eventHandlers: EventStoreInstanciators,
              store: {
                storeKey: 'game',
                write: async (key: string, value: number) => {
                      // service method to write to database
                }
peterDijk commented 2 years ago

is it maybe accessed without the NestJS module infrastructure? the answer I guess is in here but can't find more information on it import { MongoStore } from './mongo-eventstore-adapter';