Summary
Currently findByUuid and findExpired are the only query methods. In practice, teams need richer querying such as "find all instances of workflow X in state Y" or "find all instances with metadata.orderId = Z".
Proposal
Add query capabilities for workflow instances. Options include:
findByWorkflowAndState(workflowName, state) — find all instances in a given state
findByMetadata(key, value) — query by metadata fields (leveraging PostgreSQL JSONB indexing)
- A lightweight query builder for composable filters
- Pagination support for large result sets
Benefits
- Enables operational dashboards and admin tooling
- Supports business queries like "show all orders stuck in payment_pending"
- Leverages PostgreSQL's JSONB indexing capabilities for metadata queries
- Common requirement for production workflow systems
Considerations
- Query performance and indexing strategy (GIN indexes on JSONB columns)
- Whether to expose raw SQL or provide a typed query API
- Pagination and cursor-based iteration for large result sets
- Whether to support ordering (by creation date, last transition, etc.)
Summary
Currently
findByUuidandfindExpiredare the only query methods. In practice, teams need richer querying such as "find all instances of workflow X in state Y" or "find all instances with metadata.orderId = Z".Proposal
Add query capabilities for workflow instances. Options include:
findByWorkflowAndState(workflowName, state)— find all instances in a given statefindByMetadata(key, value)— query by metadata fields (leveraging PostgreSQL JSONB indexing)Benefits
Considerations