Skip to content

Commit

Permalink
fix: file names
Browse files Browse the repository at this point in the history
  • Loading branch information
fcbento committed Dec 18, 2024
1 parent 8dd5b68 commit 39874fa
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 35 deletions.
32 changes: 4 additions & 28 deletions src/repositories/pets/pets-repository.ts
Original file line number Diff line number Diff line change
@@ -1,31 +1,7 @@
import { Prisma, Pet } from "@prisma/client";
import { prisma } from "@/lib/prisma";
import { PetsRepository } from "./prisma-pets-repository";

export class PrismaPetsRepository implements PetsRepository {

async findById(id: string): Promise<Pet | null> {
const pet = await prisma.pet.findUnique({
where: {
id
}
})
return pet
}

async create(data: Prisma.PetUncheckedCreateInput): Promise<Pet> {
const pet = await prisma.pet.create({
data
})
return pet
}

async listPetsByCity(city: string): Promise<Pet[]> {
const pets = await prisma.pet.findMany({
where: {
localidade: city
}
})
return pets
}
export interface PetsRepository {
findById(id: string): Promise<Pet | null>
create(data: Prisma.PetUncheckedCreateInput): Promise<Pet>
listPetsByCity(city: string): Promise<Pet[]>
}
32 changes: 28 additions & 4 deletions src/repositories/pets/prisma-pets-repository.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,31 @@
import { Prisma, Pet } from "@prisma/client";
import { prisma } from "@/lib/prisma";
import { PetsRepository } from "./pets-repository";

export interface PetsRepository {
findById(id: string): Promise<Pet | null>
create(data: Prisma.PetUncheckedCreateInput): Promise<Pet>
listPetsByCity(city: string): Promise<Pet[]>
export class PrismaPetsRepository implements PetsRepository {

async findById(id: string): Promise<Pet | null> {
const pet = await prisma.pet.findUnique({
where: {
id
}
})
return pet
}

async create(data: Prisma.PetUncheckedCreateInput): Promise<Pet> {
const pet = await prisma.pet.create({
data
})
return pet
}

async listPetsByCity(city: string): Promise<Pet[]> {
const pets = await prisma.pet.findMany({
where: {
localidade: city
}
})
return pets
}
}
2 changes: 1 addition & 1 deletion src/services/pets/factories/get-pet-factory.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { PrismaPetsRepository } from "@/repositories/pets/pets-repository"
import { PrismaPetsRepository } from "@/repositories/pets/prisma-pets-repository"
import { GetPetService } from "../get-pet-service"

export function GetPetFacotry(){
Expand Down
2 changes: 1 addition & 1 deletion src/services/pets/factories/list-pet-factory.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { PrismaPetsRepository } from "@/repositories/pets/pets-repository"
import { PrismaPetsRepository } from "@/repositories/pets/prisma-pets-repository"
import { ListPetService } from "../list-pets-service"

export function ListPetFacotry(){
Expand Down
2 changes: 1 addition & 1 deletion src/services/pets/factories/register-pet-factory.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { PrismaPetsRepository } from "@/repositories/pets/prisma-pets-repository";
import { RegisterPetService } from "../pets-service";
import { PrismaPetsRepository } from "@/repositories/pets/pets-repository";

export function RegisterPetFacotry(){
const petsRepository = new PrismaPetsRepository()
Expand Down

0 comments on commit 39874fa

Please sign in to comment.