mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
UserTransaction Model
This commit is contained in:
parent
408c3e3f86
commit
abad8924b8
@ -19,18 +19,4 @@ export class UserTransaction extends BaseEntity {
|
|||||||
|
|
||||||
@Column({ name: 'balance_date', type: 'timestamp' })
|
@Column({ name: 'balance_date', type: 'timestamp' })
|
||||||
balanceDate: Date
|
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()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
19
backend/src/typeorm/repository/UserTransaction.ts
Normal file
19
backend/src/typeorm/repository/UserTransaction.ts
Normal 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()
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user