UserTransaction Model

This commit is contained in:
Ulf Gebhardt 2021-10-01 20:14:58 +02:00
parent 408c3e3f86
commit abad8924b8
No known key found for this signature in database
GPG Key ID: 81308EFE29ABFEBD
2 changed files with 19 additions and 14 deletions

View File

@ -19,18 +19,4 @@ export class UserTransaction extends BaseEntity {
@Column({ name: 'balance_date', type: 'timestamp' })
balanceDate: Date
static findByUserPaged(
userId: number,
limit: number,
offset: number,
order: 'ASC' | 'DESC',
): Promise<[UserTransaction[], number]> {
return this.createQueryBuilder('userTransaction')
.where('userTransaction.userId = :userId', { userId })
.orderBy('userTransaction.balanceDate', order)
.limit(limit)
.offset(offset)
.getManyAndCount()
}
}

View File

@ -0,0 +1,19 @@
import { EntityRepository, Repository } from 'typeorm'
import { UserTransaction } from '../entity/UserTransaction'
@EntityRepository(UserTransaction)
export class UserTransactionRepository extends Repository<UserTransaction> {
findByUserPaged(
userId: number,
limit: number,
offset: number,
order: 'ASC' | 'DESC',
): Promise<[UserTransaction[], number]> {
return this.createQueryBuilder('userTransaction')
.where('userTransaction.userId = :userId', { userId })
.orderBy('userTransaction.balanceDate', order)
.limit(limit)
.offset(offset)
.getManyAndCount()
}
}