Files
parcer/server/src/models/Run.ts

95 lines
2.2 KiB
TypeScript
Raw Normal View History

2024-10-09 03:27:04 +05:30
import { Model, DataTypes, Optional } from 'sequelize';
import sequelize from '../db/config';
import Robot from './Robot';
interface RunAttributes {
2024-10-09 03:27:19 +05:30
id: string;
2024-10-09 03:31:51 +05:30
robotId: string;
2024-10-09 03:27:19 +05:30
status: string;
name: string;
startedAt: Date;
finishedAt: Date;
browserId: string;
interpreterSettings: object;
log: string;
serializableRun: object;
binaryRunUrl: string;
2024-10-09 03:27:04 +05:30
}
2024-10-09 03:27:19 +05:30
interface RunCreationAttributes extends Optional<RunAttributes, 'id'> { }
2024-10-09 03:27:04 +05:30
class Run extends Model<RunAttributes, RunCreationAttributes> implements RunAttributes {
2024-10-09 03:27:19 +05:30
public id!: string;
2024-10-09 03:31:51 +05:30
public robotId!: string;
2024-10-09 03:27:19 +05:30
public status!: string;
public name!: string;
public startedAt!: Date;
public finishedAt!: Date;
public browserId!: string;
public interpreterSettings!: object;
public log!: string;
public serializableRun!: object;
public binaryRunUrl!: string;
2024-10-09 03:27:04 +05:30
}
Run.init(
2024-10-09 03:27:19 +05:30
{
id: {
type: DataTypes.UUID,
defaultValue: DataTypes.UUIDV4,
primaryKey: true,
},
2024-10-09 03:31:51 +05:30
robotId: {
2024-10-09 03:27:19 +05:30
type: DataTypes.UUID,
allowNull: false,
references: {
model: Robot,
key: 'id',
},
},
status: {
type: DataTypes.STRING(50),
allowNull: false,
},
name: {
type: DataTypes.STRING(255),
allowNull: false,
},
startedAt: {
type: DataTypes.DATE,
allowNull: false,
},
finishedAt: {
type: DataTypes.DATE,
allowNull: false,
},
browserId: {
type: DataTypes.UUID,
allowNull: false,
},
interpreterSettings: {
type: DataTypes.JSONB,
allowNull: true,
},
log: {
type: DataTypes.TEXT,
allowNull: true,
},
serializableRun: {
type: DataTypes.JSONB,
allowNull: true,
},
binaryRunUrl: {
type: DataTypes.TEXT,
allowNull: true,
},
2024-10-09 03:27:04 +05:30
},
2024-10-09 03:27:19 +05:30
{
sequelize,
tableName: 'run',
timestamps: false,
}
2024-10-09 03:27:04 +05:30
);
export default Run;