(
client: ClientContract<Schema>,
type: string,
resourceId: string,
query: Record<string, string | string[]> | undefined,
)
| 805 | } |
| 806 | |
| 807 | private async processSingleRead( |
| 808 | client: ClientContract<Schema>, |
| 809 | type: string, |
| 810 | resourceId: string, |
| 811 | query: Record<string, string | string[]> | undefined, |
| 812 | ): Promise<Response> { |
| 813 | const typeInfo = this.getModelInfo(type); |
| 814 | if (!typeInfo) { |
| 815 | return this.makeUnsupportedModelError(type); |
| 816 | } |
| 817 | |
| 818 | const { args, include, error } = this.buildSingleReadArgs(type, query); |
| 819 | if (error) return error; |
| 820 | |
| 821 | args.where = this.makeIdFilter(typeInfo.idFields, resourceId); |
| 822 | |
| 823 | const entity = await (client as any)[type].findUnique(args); |
| 824 | |
| 825 | if (entity) { |
| 826 | return { |
| 827 | status: 200, |
| 828 | body: await this.serializeItems(type, entity, { include }), |
| 829 | }; |
| 830 | } else { |
| 831 | return this.makeError('notFound'); |
| 832 | } |
| 833 | } |
| 834 | |
| 835 | private async processFetchRelated( |
| 836 | client: ClientContract<Schema>, |
no test coverage detected