@ApiFunctionGetMany
Retrieves multiple entities at once (typically by IDs or composite criteria) and enforces the same error handling and subscriber hooks as other CRUD functions.
Signature
@ApiFunctionGetMany<E extends IApiBaseEntity>(
properties: IApiFunctionProperties<E>
)Decorated methods gain the shape getMany(dto: TApiFunctionGetManyProperties<E>, eventManager?: EntityManager): Promise<Array<E>>.
Behavior
- Invokes
onBeforeGetManysubscribers that can override theFindManyOptions. - Calls
repository.findor the transactional equivalent to load the records. - Throws
NotFoundExceptionif the result set is empty so controllers surface deterministic HTTP 404 responses. - Runs
onAfterGetManysubscribers; they may adjust the returned list. - Emits
onBeforeErrorGetManyandonAfterErrorGetManysubscriber events for error observability.
Example
export class PostService {
constructor(public repository: Repository<PostEntity>) {}
@ApiFunctionGetMany<PostEntity>({ entity: PostEntity })
async getMany(properties: TApiFunctionGetManyProperties<PostEntity>) {
return [];
}
}Related resources
Last updated on