// returns nested results
export async function getLoans(spaceId: string) {
return db.query.loans.findMany({
where: eq(loans.spaceId, spaceId),
with: {
property: true,
financialInstitution: true,
},
});
}
// doesn't return nested results
export async function getLoansLJ(spaceId: string) {
return db
.select()
.from(loans)
.leftJoin(
financialInstitutions,
eq(financialInstitutions.id, loans.financialInstitutionId)
)
.where(eq(loans.spaceId, spaceId));
}
// returns nested results
export async function getLoans(spaceId: string) {
return db.query.loans.findMany({
where: eq(loans.spaceId, spaceId),
with: {
property: true,
financialInstitution: true,
},
});
}
// doesn't return nested results
export async function getLoansLJ(spaceId: string) {
return db
.select()
.from(loans)
.leftJoin(
financialInstitutions,
eq(financialInstitutions.id, loans.financialInstitutionId)
)
.where(eq(loans.spaceId, spaceId));
}