mirror of https://github.com/ghostfolio/ghostfolio
committed by
GitHub
18 changed files with 160 additions and 29 deletions
@ -0,0 +1,11 @@ |
|||
import { PrismaModule } from '@ghostfolio/api/services/prisma.module'; |
|||
import { Module } from '@nestjs/common'; |
|||
|
|||
import { TagService } from './tag.service'; |
|||
|
|||
@Module({ |
|||
exports: [TagService], |
|||
imports: [PrismaModule], |
|||
providers: [TagService] |
|||
}) |
|||
export class TagModule {} |
@ -0,0 +1,30 @@ |
|||
import { PrismaService } from '@ghostfolio/api/services/prisma.service'; |
|||
import { Injectable } from '@nestjs/common'; |
|||
|
|||
@Injectable() |
|||
export class TagService { |
|||
public constructor(private readonly prismaService: PrismaService) {} |
|||
|
|||
public async get() { |
|||
return this.prismaService.tag.findMany({ |
|||
orderBy: { |
|||
name: 'asc' |
|||
} |
|||
}); |
|||
} |
|||
|
|||
public async getByUser(userId: string) { |
|||
return this.prismaService.tag.findMany({ |
|||
orderBy: { |
|||
name: 'asc' |
|||
}, |
|||
where: { |
|||
orders: { |
|||
some: { |
|||
userId |
|||
} |
|||
} |
|||
} |
|||
}); |
|||
} |
|||
} |
Loading…
Reference in new issue