Skip to content

Commit

Permalink
Use raw select query instead of find function from typeorm (#1730)
Browse files Browse the repository at this point in the history
  • Loading branch information
ae2079 authored Jul 29, 2024
1 parent 79cac72 commit 73a56bd
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions src/repositories/donationRepository.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Between, MoreThan } from 'typeorm';
import { MoreThan } from 'typeorm';
import moment from 'moment';
import { Project } from '../entities/project';
import { Donation, DONATION_STATUS } from '../entities/donation';
Expand Down Expand Up @@ -542,11 +542,13 @@ export async function findDonationsByProjectIdWhichUseDonationBox(
endDate: Date,
projectId: number,
): Promise<Donation[]> {
return await Donation.find({
where: {
createdAt: Between(startDate, endDate),
useDonationBox: true,
projectId: projectId,
},
});
return await Donation.query(
`
SELECT * FROM donation
WHERE "createdAt" BETWEEN $1 AND $2
AND "useDonationBox" = $3
AND "projectId" = $4
`,
[startDate, endDate, true, projectId],
);
}

0 comments on commit 73a56bd

Please sign in to comment.