@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
55 lines (54 loc) • 5.85 kB
TypeScript
import { Enumerable } from '../linq/enumerable';
import { List } from '../linq/list';
import { IAsyncEnumerable } from '../linq/interfaces';
export interface IQueryable<TModel = unknown, TSelect = TModel, TWhereInput = any, TOrderByInput = any, TInclude = any, TSelectInput = any, TCreateInput = any, TUpdateInput = any, TWhereUniqueInput = any> {
readonly Provider: IQueryProvider;
readonly Expression: any;
readonly ElementType: any;
Where(where: TWhereInput): IQueryable<TModel, TSelect, TWhereInput, TOrderByInput, TInclude, TSelectInput, TCreateInput, TUpdateInput, TWhereUniqueInput>;
Select<TSelectFields extends TSelectInput>(select: TSelectFields): IQueryable<TModel, TSelectFields, TWhereInput, TOrderByInput, TInclude, TSelectInput, TCreateInput, TUpdateInput, TWhereUniqueInput>;
Include(include: TInclude): IQueryable<TModel, TSelect, TWhereInput, TOrderByInput, TInclude, TSelectInput, TCreateInput, TUpdateInput, TWhereUniqueInput>;
OrderBy(orderBy: TOrderByInput): IOrderedQueryable<TModel, TSelect, TWhereInput, TOrderByInput, TInclude, TSelectInput, TCreateInput, TUpdateInput, TWhereUniqueInput>;
SelectMany<TResult>(selector: (item: TSelect) => IQueryable<any, TResult> | IAsyncEnumerable<TResult>): IQueryable<TModel, TResult, TWhereInput, TOrderByInput, TInclude, TSelectInput, TCreateInput, TUpdateInput, TWhereUniqueInput>;
GroupBy<TKey, TElement = TSelect, TResult = IGrouping<TKey, TElement>>(keySelector: (item: TSelect) => TKey, elementSelector?: (item: TSelect) => TElement, resultSelector?: (key: TKey, group: IQueryable<TModel, TElement>) => TResult): IQueryable<TModel, TResult, TWhereInput, TOrderByInput, TInclude, TSelectInput, TCreateInput, TUpdateInput, TWhereUniqueInput>;
Join<TInner, TKey, TResult>(inner: IQueryable<any, TInner>, outerKeySelector: (outer: TSelect) => TKey, innerKeySelector: (inner: TInner) => TKey, resultSelector: (outer: TSelect, inner: TInner) => TResult): IQueryable<TModel, TResult, TWhereInput, TOrderByInput, TInclude, TSelectInput, TCreateInput, TUpdateInput, TWhereUniqueInput>;
Take(count: number): IQueryable<TModel, TSelect, TWhereInput, TOrderByInput, TInclude, TSelectInput, TCreateInput, TUpdateInput, TWhereUniqueInput>;
Skip(count: number): IQueryable<TModel, TSelect, TWhereInput, TOrderByInput, TInclude, TSelectInput, TCreateInput, TUpdateInput, TWhereUniqueInput>;
Distinct<TKey>(keySelector?: (item: TSelect) => TKey): IQueryable<TModel, TSelect, TWhereInput, TOrderByInput, TInclude, TSelectInput, TCreateInput, TUpdateInput, TWhereUniqueInput>;
Union(other: IQueryable<TModel, TSelect>): IQueryable<TModel, TSelect, TWhereInput, TOrderByInput, TInclude, TSelectInput, TCreateInput, TUpdateInput, TWhereUniqueInput>;
Intersect(other: IQueryable<TModel, TSelect>): IQueryable<TModel, TSelect, TWhereInput, TOrderByInput, TInclude, TSelectInput, TCreateInput, TUpdateInput, TWhereUniqueInput>;
Except(other: IQueryable<TModel, TSelect>): IQueryable<TModel, TSelect, TWhereInput, TOrderByInput, TInclude, TSelectInput, TCreateInput, TUpdateInput, TWhereUniqueInput>;
ExecuteAsync(): Promise<TSelect[]>;
FirstAsync(predicate?: (item: TSelect) => boolean | Promise<boolean>): Promise<TSelect>;
FirstOrDefaultAsync(predicate?: (item: TSelect) => boolean | Promise<boolean>): Promise<TSelect | undefined>;
SingleAsync(predicate?: (item: TSelect) => boolean | Promise<boolean>): Promise<TSelect>;
SingleOrDefaultAsync(predicate?: (item: TSelect) => boolean | Promise<boolean>): Promise<TSelect | undefined>;
LastAsync(predicate?: (item: TSelect) => boolean | Promise<boolean>): Promise<TSelect>;
LastOrDefaultAsync(predicate?: (item: TSelect) => boolean | Promise<boolean>): Promise<TSelect | undefined>;
AnyAsync(predicate?: (item: TSelect) => boolean | Promise<boolean>): Promise<boolean>;
AllAsync(predicate: (item: TSelect) => boolean | Promise<boolean>): Promise<boolean>;
CountAsync(predicate?: (item: TSelect) => boolean | Promise<boolean>): Promise<number>;
LongCountAsync(predicate?: (item: TSelect) => boolean | Promise<boolean>): Promise<number>;
SumAsync(selector?: (item: TSelect) => number): Promise<number>;
AverageAsync(selector?: (item: TSelect) => number): Promise<number>;
MinAsync<TResult>(selector?: (item: TSelect) => TResult): Promise<TResult>;
MaxAsync<TResult>(selector?: (item: TSelect) => TResult): Promise<TResult>;
ToArrayAsync(): Promise<TSelect[]>;
ToListAsync(): Promise<List<TSelect>>;
ForEachAsync(action: (item: TSelect) => void | Promise<void>): Promise<void>;
AggregateAsync<TAccumulate>(seed: TAccumulate, func: (accumulate: TAccumulate, item: TSelect) => Promise<TAccumulate> | TAccumulate): Promise<TAccumulate>;
ContainsAsync(item: TSelect): Promise<boolean>;
ToEnumerable(): Promise<Enumerable<TSelect>>;
}
export interface IOrderedQueryable<TModel = unknown, TSelect = TModel, TWhereInput = any, TOrderByInput = any, TInclude = any, TSelectInput = any, TCreateInput = any, TUpdateInput = any, TWhereUniqueInput = any> extends IQueryable<TModel, TSelect, TWhereInput, TOrderByInput, TInclude, TSelectInput, TCreateInput, TUpdateInput, TWhereUniqueInput> {
ThenBy(orderBy: TOrderByInput): IOrderedQueryable<TModel, TSelect, TWhereInput, TOrderByInput, TInclude, TSelectInput, TCreateInput, TUpdateInput, TWhereUniqueInput>;
ThenByDescending(orderBy: TOrderByInput): IOrderedQueryable<TModel, TSelect, TWhereInput, TOrderByInput, TInclude, TSelectInput, TCreateInput, TUpdateInput, TWhereUniqueInput>;
}
export interface IQueryProvider {
Execute<TResult>(expression: any): Promise<TResult>;
CreateQuery<TElement>(expression: any): IQueryable<TElement>;
}
export interface IGrouping<TKey, TElement> {
readonly Key: TKey;
readonly Elements: IQueryable<TElement>;
}