type BooleanWhere = { $and?: WhereParams[]; $or?: WhereParams[]; $not?: WhereParams; }; type WhereParams = { [K in keyof T]?: T[K]; } & BooleanWhere; type Sortables = { // check sortable [P in keyof T]: P; }[keyof T]; type Direction = 'asc' | 'ASC' | 'DESC' | 'desc'; type FindParams = { select?: (keyof T)[]; // TODO: add nested operators & relations where?: WhereParams; limit?: number; offset?: number; orderBy?: // TODO: add relations | Sortables | Sortables[] | { [K in Sortables]?: Direction } | { [K in Sortables]?: Direction }[]; }; interface QueryFromContentType { findOne(params: FindParams): AllTypes[T]; findMany(params: FindParams): AllTypes[T][]; } interface ModelConfig { tableName: string; [k: string]: any; } export class Database { static transformContentTypes(contentTypes: any[]): ModelConfig[]; query(uid: T): QueryFromContentType; }