diff --git a/backend/models/associations.js b/backend/models/associations.js index d445af5..1f417aa 100644 --- a/backend/models/associations.js +++ b/backend/models/associations.js @@ -569,14 +569,14 @@ export default function setupAssociations() { Party.belongsToMany(TitleOfNobility, { through: PartyInvitedNobility, - foreignKey: 'party_id', - otherKey: 'title_of_nobility_id', + foreignKey: 'partyId', + otherKey: 'titleOfNobilityId', as: 'invitedNobilities', }); TitleOfNobility.belongsToMany(Party, { through: PartyInvitedNobility, - foreignKey: 'title_of_nobility_id', - otherKey: 'party_id', + foreignKey: 'titleOfNobilityId', + otherKey: 'partyId', as: 'partiesInvitedTo', }); diff --git a/backend/services/falukantService.js b/backend/services/falukantService.js index de1d370..e5bb5f4 100644 --- a/backend/services/falukantService.js +++ b/backend/services/falukantService.js @@ -3225,6 +3225,10 @@ class FalukantService extends BaseService { cost: cost }); if (nobilities.length > 0) { + // Stelle sicher, dass die Party eine ID hat + if (!party.id) { + throw new Error('Party wurde erstellt, hat aber keine ID'); + } // Verwende die bereits geladenen Objekte await party.addInvitedNobilities(nobilities); }