Searching data older than a Date with typeORM
You can use MoreThan, the doc
async filesListToDelete(): Promise<any> { return await this.fileRepository.find({ where: { last_modified: MoreThan('2018-11-15 10:41:30.746877') },});}
Also you can do this using createQueryBuilder
as below:
public async filesListToDelete(): Promise<any> { let record = await this.fileRepository.createQueryBuilder('file') .where('file.last_modified > :start_at', { start_at: '2018-11-15 10:41:30.746877' }) .getMany(); return record }
Either of these will fetch OLDER
data
with built-in TypeORM
operator (docs)
async filesListToDelete(): Promise<any> { return await this.fileRepository.find({ where: { last_modified: LessThan('2018-11-15 10:41:30.746877') }, });}
with PostgreSQL
operator (docs)
public async filesListToDelete(): Promise<any> { let record = await this.fileRepository.createQueryBuilder('file') .where('file.last_modified < :start_at', { start_at: '2018-11-15 10:41:30.746877' }) .getMany(); return record}