hy'
- User
hy'
- Assistant
Hello! How can I assist you today?
- User
const currentMonth = startdate.getMonth() + const currentYear = startdate.getFullYear(); const FgbRepository = getRepository(Fgbscore); i want get the month wsie
- Assistant
To get the data month-wise from
Fgbscorerepository, you can use theQueryBuilderprovided by TypeORM. Here's an example of how you can achieve that:const currentMonth = startdate.getMonth() + 1; // Adding 1 to get the correct month value const currentYear = startdate.getFullYear(); const FgbRepository = getRepository(Fgbscore); const results = await FgbRepository .createQueryBuilder("fgbscore") // Use your entity name here ("fgbscore" should be replaced) .where("MONTH(fgbscore.date) = :month AND YEAR(fgbscore.date) = :year", { month: currentMonth, year: currentYear }) .getMany();In the above code, we create a
QueryBuilderfor theFgbscoreentity and use thewheremethod to filter the results based on the month and year. TheMONTHandYEARfunctions are used to extract the month and year from thedatecolumn (change it to the actual column name in your case). Finally, we retrieve the results using thegetManymethod.Note: Make sure to replace "fgbscore" with the actual entity name in the method. Also, adjust the column name according to your entity's schema.