fix persisting of many to many entity

This commit is contained in:
dswbx
2025-02-18 15:43:19 +01:00
parent 400db84dd5
commit f494735a79
12 changed files with 86 additions and 70 deletions

View File

@@ -73,7 +73,6 @@ export class Repository<TBD extends object = DefaultDB, TB extends keyof TBD = a
sort: entity.getDefaultSort(),
select: entity.getSelect()
};
//console.log("validated", validated);
if (!options) return validated;
@@ -144,7 +143,9 @@ export class Repository<TBD extends object = DefaultDB, TB extends keyof TBD = a
});
if (invalid.length > 0) {
throw new InvalidSearchParamsException(`Invalid where field(s): ${invalid.join(", ")}`);
throw new InvalidSearchParamsException(
`Invalid where field(s): ${invalid.join(", ")}`
).context({ aliases, entity: entity.name });
}
validated.where = options.where;
@@ -334,7 +335,6 @@ export class Repository<TBD extends object = DefaultDB, TB extends keyof TBD = a
async findMany(_options?: Partial<RepoQuery>): Promise<RepositoryResponse<TBD[TB][]>> {
const { qb, options } = this.buildQuery(_options);
//console.log("findMany:options", options);
await this.emgr.emit(
new Repository.Events.RepositoryFindManyBefore({ entity: this.entity, options })
@@ -386,7 +386,6 @@ export class Repository<TBD extends object = DefaultDB, TB extends keyof TBD = a
}
};
//console.log("findManyOptions", newEntity.name, findManyOptions);
return this.cloneFor(newEntity).findMany(findManyOptions);
}