Skip to main content
Category is a workspace-global catalog entity representing a named classification tag that can be applied to companies or transactions. It is not workspace-scoped itself — it acts as a shared taxonomy that any workspace can reference through the CompanyCategory pivot. A category carries a category_type discriminator (company or transaction) that controls which entity type it may label, and a name string that is the human-visible label.

API operations

Data model

Attributes

System-computed

  • category_id is generated at insert by the Postgres expression gen_random_uuid() (defaultRaw). It is unique and immutable.
  • created_at is set by the MikroORM onCreate lifecycle hook to new Date() at insertion time.
  • updated_at is set by both onCreate and onUpdate lifecycle hooks; tracks last modification.
  • deleted_at is null on active records and set to the deletion timestamp on soft-delete. All queries must filter deleted_at IS NULL.
  • category_type defaults to CategoryTypeEnum.COMPANY (‘company’) at the entity level. The DB column carries NOT NULL DEFAULT 'company' via the category_type_enum native PG type added in Migration20260528120000.
  • The partial composite index idx_categories_category_type_active ON core_api.categories (category_type, name) WHERE deleted_at IS NULL is maintained for fast lookup by type within the active catalog.
  • Category is a global (non-workspace-scoped) catalog entity — it has no workspace_pk column. Workspace-level association is achieved exclusively through the CompanyCategory pivot, which joins a workspace-scoped Company to a global Category.
  • Transaction-type catalog entries were seeded by Migration20260528120000 with a fixed list of standard transaction category names (e.g. ‘Payroll’, ‘Rent’, ‘Tax’, etc.).

Example

Source: apps/api/src/database/entities/Category.ts · domain: financial-graph · tier: Supporting