mirror of https://github.com/ghostfolio/ghostfolio
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
31 lines
923 B
31 lines
923 B
import { AccountBalances } from '@ghostfolio/api/app/account/interfaces/account-balances.interface';
|
|
import { PrismaService } from '@ghostfolio/api/services/prisma/prisma.service';
|
|
import { Injectable } from '@nestjs/common';
|
|
import { AccountBalance, Prisma } from '@prisma/client';
|
|
|
|
@Injectable()
|
|
export class AccountBalanceService {
|
|
public constructor(private readonly prismaService: PrismaService) {}
|
|
|
|
public async createAccountBalance(
|
|
data: Prisma.AccountBalanceCreateInput
|
|
): Promise<AccountBalance> {
|
|
return this.prismaService.accountBalance.create({
|
|
data
|
|
});
|
|
}
|
|
|
|
public async getAccountBalances(accountId: string): Promise<AccountBalances> {
|
|
const balances = await this.prismaService.accountBalance.findMany({
|
|
where: {
|
|
accountId: accountId,
|
|
},
|
|
select: {
|
|
date: true,
|
|
id: true,
|
|
value: true
|
|
}
|
|
});
|
|
return { balances }
|
|
}
|
|
}
|
|
|