mirror of
https://github.com/shishantbiswas/bknd.git
synced 2026-03-16 04:27:21 +00:00
Fix entity referencing issue during post-seeded relational fetch
This commit is contained in:
@@ -107,15 +107,15 @@ export class EntityManager<TBD extends object = DefaultDB> {
|
||||
}
|
||||
|
||||
this._entities[entityIndex] = entity;
|
||||
|
||||
// caused issues because this.entity() was using a reference (for when initial config was given)
|
||||
}
|
||||
|
||||
entity(e: Entity | keyof TBD | string): Entity {
|
||||
let entity: Entity | undefined;
|
||||
if (typeof e === "string") {
|
||||
entity = this.entities.find((entity) => entity.name === e);
|
||||
} else if (e instanceof Entity) {
|
||||
entity = e;
|
||||
}
|
||||
// make sure to always retrieve by name
|
||||
const entity = this.entities.find((entity) =>
|
||||
e instanceof Entity ? entity.name === e.name : entity.name === e
|
||||
);
|
||||
|
||||
if (!entity) {
|
||||
// @ts-ignore
|
||||
|
||||
Reference in New Issue
Block a user