Created
February 29, 2024 17:05
-
-
Save dpickett/58da223ce9252df4df5c22f3fd1d2b7d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Prisma } from "../prisma.js"; | |
import { DatabaseClient } from "../prisma/DatabaseClient.js"; | |
export type IdType = string | |
export type CreateInput = Prisma.DiscoveryCallCreateInput | |
export type UpdateInput = Prisma.DiscoveryCallUpdateInput | |
export type WhereInput = Prisma.DiscoveryCallWhereInput | |
export type WhereUniqueInput = Prisma.DiscoveryCallWhereUniqueInput | |
export type OrderByInput = Prisma.DiscoveryCallOrderByWithRelationInput | Prisma.DiscoveryCallOrderByWithRelationInput[] | |
export class DiscoveryCallRepository { | |
private model: Prisma.DiscoveryCallDelegate | |
constructor() { | |
this.model = DatabaseClient.getInstance().prisma.discoveryCall | |
} | |
async findById(id: IdType) { | |
return this.model.findFirst({ where: { id: { equals: id } } }) | |
} | |
async findMany({ orderBy, where, skip, take, cursor }: { orderBy?: OrderByInput, where?: WhereInput, skip?: number, take?: number, cursor?: WhereUniqueInput }) { | |
return this.model.findMany({ orderBy, where, skip, take, cursor }) | |
} | |
async create(args: CreateInput) { | |
return this.model.create({ data: args }) | |
} | |
async delete(id: IdType) { | |
return this.model.delete({ where: { id } }) | |
} | |
async update(id: IdType, data: Omit<UpdateInput, "id">) { | |
return this.model.update({ where: { id: id }, data }) | |
} | |
async upsert(where: WhereUniqueInput, update: UpdateInput, create: CreateInput) { | |
return this.model.upsert({ where, update, create }) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment