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