typeorm-linq-repository icon indicating copy to clipboard operation
typeorm-linq-repository copied to clipboard

Get MAX/MIN value

Open longtruongagn003 opened this issue 5 years ago • 1 comments

Hi,

I using lib, but cannot find syntax get MAX/MIN value (ID: number) on a Table

Thanks.

longtruongagn003 avatar Oct 15 '19 08:10 longtruongagn003

Hi @longpro1601,

I will look into an elegant way to implement this into the lib's syntax, but in the meantime, you can use:

await repository
    .typeormRepository
    .createQueryBuilder("entity")
    .select("MAX(entity.id)", "max")
    .getRawOne();

IRCraziestTaxi avatar Oct 15 '19 14:10 IRCraziestTaxi