diff --git a/packages/backend/src/models/flow.ts b/packages/backend/src/models/flow.ts index 01733ded..458175d6 100644 --- a/packages/backend/src/models/flow.ts +++ b/packages/backend/src/models/flow.ts @@ -1,5 +1,5 @@ import { ValidationError } from 'objection'; -import type { ModelOptions, QueryContext } from 'objection'; +import type { ModelOptions, QueryContext, QueryBuilder } from 'objection'; import Base from './base'; import Step from './step'; import Execution from './execution'; @@ -33,6 +33,9 @@ class Flow extends Base { from: 'flows.id', to: 'steps.flow_id', }, + filter(builder: QueryBuilder) { + builder.orderBy('position', 'asc'); + }, }, executions: { relation: Base.HasManyRelation, @@ -44,7 +47,10 @@ class Flow extends Base { }, }); - async $beforeUpdate(opt: ModelOptions, queryContext: QueryContext): Promise { + async $beforeUpdate( + opt: ModelOptions, + queryContext: QueryContext + ): Promise { await super.$beforeUpdate(opt, queryContext); if (!this.active) return;