Skip to content

Instantly share code, notes, and snippets.

@dpickett
Created February 29, 2024 17:05
Show Gist options
  • Save dpickett/58da223ce9252df4df5c22f3fd1d2b7d to your computer and use it in GitHub Desktop.
Save dpickett/58da223ce9252df4df5c22f3fd1d2b7d to your computer and use it in GitHub Desktop.
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