Skip to content

Commit 39730b4

Browse files
committed
Used query to get GuestStayDetails
1 parent 2839ad8 commit 39730b4

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

src/guestStayAccounts/api/api.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import {
3232
initialState,
3333
toGuestStayAccountId,
3434
} from '../guestStayAccount';
35+
import { getGuestStayDetails } from '../guestStayDetails';
3536

3637
export const handle = CommandHandler(evolve, initialState);
3738

@@ -186,10 +187,10 @@ export const guestStayAccountsApi =
186187
on(async (request: GetShoppingCartRequest) => {
187188
const guestStayAccountId = parseGuestStayAccountId(request.params);
188189

189-
const result = await eventStore.aggregateStream(guestStayAccountId, {
190-
evolve,
191-
initialState,
192-
});
190+
const result = await getGuestStayDetails(
191+
eventStore,
192+
guestStayAccountId,
193+
);
193194

194195
if (result === null) return NotFound();
195196

src/guestStayAccounts/guestStayDetails.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { type EventStore } from '@event-driven-io/emmett';
12
import type { GuestStayAccountEvent } from './guestStayAccount';
23

34
export type NotExisting = { status: 'NotExisting' };
@@ -83,3 +84,12 @@ export const evolve = (
8384
}
8485
}
8586
};
87+
88+
export const getGuestStayDetails = (
89+
eventStore: EventStore,
90+
guestStayAccountId: string,
91+
) =>
92+
eventStore.aggregateStream(guestStayAccountId, {
93+
evolve,
94+
initialState,
95+
});

0 commit comments

Comments
 (0)