Files
automatisch/packages/backend/src/models/execution.ts
2022-02-26 20:29:44 +03:00

44 lines
874 B
TypeScript

import Base from './base';
import Flow from './flow';
import ExecutionStep from './execution-step';
class Execution extends Base {
id!: string;
flowId!: string;
testRun: boolean;
executionSteps: ExecutionStep[];
static tableName = 'executions';
static jsonSchema = {
type: 'object',
properties: {
id: { type: 'string' },
flowId: { type: 'integer' },
testRun: { type: 'boolean' },
},
};
static relationMappings = () => ({
flow: {
relation: Base.BelongsToOneRelation,
modelClass: Flow,
join: {
from: 'executions.flow_id',
to: 'flows.id',
},
},
executionSteps: {
relation: Base.HasManyRelation,
modelClass: ExecutionStep,
join: {
from: 'executions.id',
to: 'execution_steps.execution_id',
},
},
});
}
export default Execution;