UNPKG

@algochad/prisma-core

Version:

A comprehensive NestJS library that provides EF-Core-like operations using Prisma and GraphQL. Features LINQ-style query builders, advanced data manipulation, GraphQL integration with genql, and a unified API for both Prisma and GraphQL operations. Includ

83 lines (82 loc) 6.28 kB
import { IEnumerable, IQueryable } from '../../collections'; import { IGenQLClient } from '../../collections/graphql/graphql-queryable'; type SelectResult<TModel, TSelectInput> = TSelectInput extends Record<string, any> ? { [K in keyof TSelectInput as TSelectInput[K] extends true ? K : never]: K extends keyof TModel ? TModel[K] : never; } : TSelectInput; export declare class GraphQLUnifiedBuilder<TModel = unknown, TSelect = TModel, TWhereInput = any, TOrderByInput = any, TInclude = any, TSelectInput = any, TCreateInput = any, TUpdateInput = any, TWhereUniqueInput = any> { private readonly queryBuilder; private readonly mutationBuilder; constructor(genqlClient: IGenQLClient, queryOperationName: string, mutationOperationNames: { create: string; createMany?: string; update: string; updateMany?: string; upsert?: string; delete: string; deleteMany?: string; }, operationType?: 'query' | 'mutation' | 'subscription'); factory: () => GraphQLUnifiedBuilder<TModel, TSelect, TWhereInput, TOrderByInput, TInclude, TSelectInput, TCreateInput, TUpdateInput, TWhereUniqueInput>; Where(where: TWhereInput): this; Select<TSelectFields extends TSelectInput>(select: TSelectFields): GraphQLUnifiedBuilder<TModel, SelectResult<TModel, TSelectFields>, TWhereInput, TOrderByInput, TInclude, TSelectInput, TCreateInput, TUpdateInput, TWhereUniqueInput>; Include(include: TInclude): this; OrderBy(orderBy: TOrderByInput): this; Take(n: number): this; Skip(n: number): this; ToEnumerable(): Promise<IEnumerable<TSelect>>; ToArray(): Promise<TSelect[]>; First(): Promise<TSelect | null>; FirstOrDefault(): Promise<TSelect | undefined>; Single(): Promise<TSelect | null>; Count(): Promise<number>; Exists(): Promise<boolean>; Any(): Promise<boolean>; Min(field: string): Promise<any>; Max(field: string): Promise<any>; Sum(field: string): Promise<number>; Avg(field: string): Promise<number>; Project<TResult>(selector: (item: TSelect) => TResult): Promise<IEnumerable<TResult>>; Create(data: TCreateInput): Promise<TModel>; CreateMany(data: TCreateInput[]): Promise<{ count: number; } | TModel[]>; Update(where: TWhereUniqueInput, data: TUpdateInput): Promise<TModel>; UpdateMany(where: TWhereInput, data: TUpdateInput): Promise<{ count: number; }>; Upsert(where: TWhereUniqueInput, create: TCreateInput, update: TUpdateInput): Promise<TModel>; Delete(where: TWhereUniqueInput): Promise<TModel>; DeleteMany(where: TWhereInput): Promise<{ count: number; }>; BulkUpsert(records: Array<{ where: TWhereUniqueInput; create: TCreateInput; update: TUpdateInput; }>): Promise<TModel[]>; ExecuteCustomMutation(operationName: string, args: any, selection?: any): Promise<any>; ExecuteBatch(mutations: Array<{ operationName: string; args: any; selection?: any; }>): Promise<any[]>; AsQueryable(): IQueryable<TModel, TSelect, TWhereInput, TOrderByInput, TInclude, TSelectInput, TCreateInput, TUpdateInput, TWhereUniqueInput>; ContextFactory(): GraphQLUnifiedBuilder<TModel, TSelect, TWhereInput, TOrderByInput, TInclude, TSelectInput, TCreateInput, TUpdateInput, TWhereUniqueInput>; Fresh(): GraphQLUnifiedBuilder<TModel, TSelect, TWhereInput, TOrderByInput, TInclude, TSelectInput, TCreateInput, TUpdateInput, TWhereUniqueInput>; New(): GraphQLUnifiedBuilder<TModel, TSelect, TWhereInput, TOrderByInput, TInclude, TSelectInput, TCreateInput, TUpdateInput, TWhereUniqueInput>; Subscribe(): AsyncIterable<TSelect>; AsAsyncEnumerable(): import("../../collections").IAsyncEnumerable<TSelect>; WhereEquals(field: keyof TModel, value: any): GraphQLUnifiedBuilder<TModel, TSelect, TWhereInput, TOrderByInput, TInclude, TSelectInput, TCreateInput, TUpdateInput, TWhereUniqueInput>; WhereContains(field: keyof TModel, value: string): GraphQLUnifiedBuilder<TModel, TSelect, TWhereInput, TOrderByInput, TInclude, TSelectInput, TCreateInput, TUpdateInput, TWhereUniqueInput>; WhereStartsWith(field: keyof TModel, value: string): GraphQLUnifiedBuilder<TModel, TSelect, TWhereInput, TOrderByInput, TInclude, TSelectInput, TCreateInput, TUpdateInput, TWhereUniqueInput>; WhereEndsWith(field: keyof TModel, value: string): GraphQLUnifiedBuilder<TModel, TSelect, TWhereInput, TOrderByInput, TInclude, TSelectInput, TCreateInput, TUpdateInput, TWhereUniqueInput>; WhereIn(field: keyof TModel, values: any[]): GraphQLUnifiedBuilder<TModel, TSelect, TWhereInput, TOrderByInput, TInclude, TSelectInput, TCreateInput, TUpdateInput, TWhereUniqueInput>; WhereNotIn(field: keyof TModel, values: any[]): GraphQLUnifiedBuilder<TModel, TSelect, TWhereInput, TOrderByInput, TInclude, TSelectInput, TCreateInput, TUpdateInput, TWhereUniqueInput>; WhereGreaterThan(field: keyof TModel, value: any): GraphQLUnifiedBuilder<TModel, TSelect, TWhereInput, TOrderByInput, TInclude, TSelectInput, TCreateInput, TUpdateInput, TWhereUniqueInput>; WhereGreaterThanOrEqual(field: keyof TModel, value: any): GraphQLUnifiedBuilder<TModel, TSelect, TWhereInput, TOrderByInput, TInclude, TSelectInput, TCreateInput, TUpdateInput, TWhereUniqueInput>; WhereLessThan(field: keyof TModel, value: any): GraphQLUnifiedBuilder<TModel, TSelect, TWhereInput, TOrderByInput, TInclude, TSelectInput, TCreateInput, TUpdateInput, TWhereUniqueInput>; WhereLessThanOrEqual(field: keyof TModel, value: any): GraphQLUnifiedBuilder<TModel, TSelect, TWhereInput, TOrderByInput, TInclude, TSelectInput, TCreateInput, TUpdateInput, TWhereUniqueInput>; WhereBetween(field: keyof TModel, min: any, max: any): GraphQLUnifiedBuilder<TModel, TSelect, TWhereInput, TOrderByInput, TInclude, TSelectInput, TCreateInput, TUpdateInput, TWhereUniqueInput>; WhereNull(field: keyof TModel): GraphQLUnifiedBuilder<TModel, TSelect, TWhereInput, TOrderByInput, TInclude, TSelectInput, TCreateInput, TUpdateInput, TWhereUniqueInput>; WhereNotNull(field: keyof TModel): GraphQLUnifiedBuilder<TModel, TSelect, TWhereInput, TOrderByInput, TInclude, TSelectInput, TCreateInput, TUpdateInput, TWhereUniqueInput>; } export {};