feat: user and robot relation
This commit is contained in:
@@ -1,6 +1,8 @@
|
|||||||
import { Model, DataTypes, Optional } from 'sequelize';
|
import { Model, DataTypes, Optional } from 'sequelize';
|
||||||
import sequelize from '../storage/db';
|
import sequelize from '../storage/db';
|
||||||
import { WorkflowFile, Where, What, WhereWhatPair } from 'maxun-core';
|
import { WorkflowFile, Where, What, WhereWhatPair } from 'maxun-core';
|
||||||
|
import User from './User'; // Import User model
|
||||||
|
import Run from './Run';
|
||||||
|
|
||||||
interface RobotMeta {
|
interface RobotMeta {
|
||||||
name: string;
|
name: string;
|
||||||
@@ -82,4 +84,9 @@ Robot.init(
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
Robot.hasMany(Run, {
|
||||||
|
foreignKey: 'robotId',
|
||||||
|
as: 'runs', // Alias for the relation
|
||||||
|
});
|
||||||
|
|
||||||
export default Robot;
|
export default Robot;
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
import { DataTypes, Model, Optional } from 'sequelize';
|
import { DataTypes, Model, Optional } from 'sequelize';
|
||||||
import sequelize from '../storage/db';
|
import sequelize from '../storage/db';
|
||||||
|
import Robot from './Robot';
|
||||||
|
|
||||||
interface UserAttributes {
|
interface UserAttributes {
|
||||||
id: number;
|
id: number;
|
||||||
@@ -79,4 +80,9 @@ User.init(
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
User.hasMany(Robot, {
|
||||||
|
foreignKey: 'userId',
|
||||||
|
as: 'robots', // Alias for the relation
|
||||||
|
});
|
||||||
|
|
||||||
export default User;
|
export default User;
|
||||||
|
|||||||
Reference in New Issue
Block a user