UNPKG

@jokio/datastore

Version:

Helper library for Google Cloud Datastore

43 lines (42 loc) 1.3 kB
import { AggregateRoot, Entity, DomainEvent, Aggregate } from "../../"; export declare class CustomerAggregate extends AggregateRoot<CustomerState> { static Events: { Registered: DomainEvent<CustomerRegisteredEvent>; AccountsCountUpdated: DomainEvent<AccountsCountUpdatedEvent>; }; aggregates: { operations: OperationsAggregate; }; constructor(datastore: any, parentTransaction: any); register(props: RegisterCustomerProps): Promise<CustomerState>; updateAccountsCount(props: UpdateAccountsCountProps): Promise<CustomerState>; } export interface CustomerState extends Entity { name: string; accountsCount: number; operations: OperationsState; } export interface RegisterCustomerProps { name: string; } export interface UpdateAccountsCountProps { operationType: 'add' | 'remove'; } export interface CustomerRegisteredEvent { id: string; name: string; accountsCount: number; } export interface AccountsCountUpdatedEvent { customerId: string; totalCount: number; } export declare class OperationsAggregate extends Aggregate<OperationsState> { defaultState: { count: number; }; add(): void; } export interface OperationsState { count: number; }