Arthur
Arthur
PPrisma
Created by Arthur on 9/10/2024 in #help-and-questions
Return Type With Relations
Thank you for your answer, I'll read more about this include your approach.
7 replies
PPrisma
Created by Arthur on 9/10/2024 in #help-and-questions
Return Type With Relations
It's only works when I create the type by myself:
import { Loan, Customer } from '@prisma/client';

export type FindLoanDetailsEntity = Loan & {
customer: Customer;
};
import { Loan, Customer } from '@prisma/client';

export type FindLoanDetailsEntity = Loan & {
customer: Customer;
};
7 replies
PPrisma
Created by Arthur on 9/10/2024 in #help-and-questions
Return Type With Relations
Usage of the method:
const result = await this.loanRepository.findLoanDetails({ id: loanId });
console.log(result.customer);
const result = await this.loanRepository.findLoanDetails({ id: loanId });
console.log(result.customer);
The error:
TS2339: Property customer does not exist on type
TS2339: Property customer does not exist on type
7 replies
PPrisma
Created by Arthur on 9/10/2024 in #help-and-questions
Return Type With Relations
Sure,
import { Loan, Prisma } from '@prisma/client';

async findLoanDetails<T extends Prisma.LoanWhereInput>(where: T): Promise<Loan> {
return this.prismaService.loan.findFirst({
where,
include: {
customer: true,
},
});
}
import { Loan, Prisma } from '@prisma/client';

async findLoanDetails<T extends Prisma.LoanWhereInput>(where: T): Promise<Loan> {
return this.prismaService.loan.findFirst({
where,
include: {
customer: true,
},
});
}
7 replies
PPrisma
Created by Arthur on 7/29/2024 in #help-and-questions
Upsert by Reference ID
Thx!
7 replies
PPrisma
Created by Arthur on 7/29/2024 in #help-and-questions
Upsert by Reference ID
7 replies
PPrisma
Created by Arthur on 7/29/2024 in #help-and-questions
Upsert by Reference ID
@Nurul (Prisma) So basically the issue is, that loan_id is not unique. Do I understand correctly?
7 replies