Skip to main content

addEntityToDomain

Callable

  • addEntityToDomain(directory: string): (id: string, entity: { id: string; version: string }, version?: string) => Promise<void>

  • Add an entity to a domain by its id. Optionally specify a version to add the entity to a specific version of the domain.

    @example
    import utils from '@eventcatalog/utils';

    // Adds an entity to the domain
    const { addEntityToDomain } = utils('/path/to/eventcatalog');

    // Adds an entity (User) to the domain (Orders)
    await addEntityToDomain('Orders', { id: 'User', version: '1.0.0' });
    // Adds an entity (Product) to the domain (Orders) with a specific version
    await addEntityToDomain('Orders', { id: 'Product', version: '2.0.0' }, '1.0.0');