mirror of
https://github.com/n08i40k/schedule-parser-next.git
synced 2025-12-06 17:57:45 +03:00
1.0.0
This commit is contained in:
9
src/users/users.module.ts
Normal file
9
src/users/users.module.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
import { Module } from "@nestjs/common";
|
||||
import { UsersService } from "./users.service";
|
||||
import { PrismaService } from "../prisma/prisma.service";
|
||||
|
||||
@Module({
|
||||
providers: [PrismaService, UsersService],
|
||||
exports: [UsersService],
|
||||
})
|
||||
export class UsersModule {}
|
||||
31
src/users/users.service.ts
Normal file
31
src/users/users.service.ts
Normal file
@@ -0,0 +1,31 @@
|
||||
import { Injectable } from "@nestjs/common";
|
||||
import { PrismaService } from "../prisma/prisma.service";
|
||||
import { Prisma, user } from "@prisma/client";
|
||||
|
||||
@Injectable()
|
||||
export class UsersService {
|
||||
constructor(private readonly prismaService: PrismaService) {}
|
||||
|
||||
async findUnique(where: Prisma.userWhereUniqueInput): Promise<user | null> {
|
||||
return this.prismaService.user.findUnique({ where: where });
|
||||
}
|
||||
|
||||
async findOne(where: Prisma.userWhereInput): Promise<user | null> {
|
||||
return this.prismaService.user.findFirst({ where: where });
|
||||
}
|
||||
|
||||
async update(params: {
|
||||
where: Prisma.userWhereUniqueInput;
|
||||
data: Prisma.userUpdateInput;
|
||||
}): Promise<user | null> {
|
||||
return this.prismaService.user.update(params);
|
||||
}
|
||||
|
||||
async create(data: Prisma.userCreateInput): Promise<user> {
|
||||
return this.prismaService.user.create({ data });
|
||||
}
|
||||
|
||||
async has(where: Prisma.userWhereUniqueInput): Promise<boolean> {
|
||||
return (await this.prismaService.user.count({ where })) > 0;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user