Skip to content

Commit

Permalink
Avoid creating duplicates in type indexes
Browse files Browse the repository at this point in the history
  • Loading branch information
NoelDeMartin committed Feb 19, 2025
1 parent 21f96a5 commit a24689b
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/models/SolidContainer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,16 @@ export default class SolidContainer extends Model {

await typeIndex.withEngine(this.requireEngine(), async () => {
await typeIndex.loadRelationIfUnloaded('registrations');

const alreadyRegistered = typeIndex.registrations.some(registration => {
return typeRegistration.instanceContainer === registration.instanceContainer
&& !typeRegistration.forClass.some(type => !registration.forClass.includes(type));
});

if (alreadyRegistered) {
return;
}

await typeIndex.relatedRegistrations.create(typeRegistration);
});
}
Expand Down

0 comments on commit a24689b

Please sign in to comment.