import User from './community/user.js'; import UserParam from './community/user_param.js'; import UserParamType from './type/user_param.js'; import UserRightType from './type/user_right.js'; import UserRight from './community/user_right.js'; import SettingsType from './type/settings.js'; import UserParamValue from './type/user_param_value.js'; export default function setupAssociations() { SettingsType.hasMany(UserParamType, { foreignKey: 'settingsId', as: 'user_param_types' }); UserParamType.belongsTo(SettingsType, { foreignKey: 'settingsId', as: 'settings_type' }); UserParamType.hasMany(UserParam, { foreignKey: 'paramTypeId', as: 'user_params' }); UserParam.belongsTo(UserParamType, { foreignKey: 'paramTypeId', as: 'paramType' }); UserParam.belongsTo(SettingsType, { foreignKey: 'settingsId', as: 'settings' }); UserParam.belongsTo(User, { foreignKey: 'userId', as: 'user' }); UserRight.belongsTo(User, { foreignKey: 'userId' }); UserRight.belongsTo(UserRightType, { foreignKey: 'rightTypeId', as: 'rightType' }); UserParamType.hasMany(UserParamValue, { foreignKey: 'userParamTypeId', as: 'user_param_values' }); UserParamValue.belongsTo(UserParamType, { foreignKey: 'userParamTypeId', as: 'user_param_type' }); }