nestjs-event-store icon indicating copy to clipboard operation
nestjs-event-store copied to clipboard

how to access service in IAdapterStore?

Open peterDijk opened this issue 3 years ago • 1 comments

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 avatar Dec 06 '21 12:12 peterDijk

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';

peterDijk avatar Dec 06 '21 13:12 peterDijk