import Class from './class'; import Query from './query'; import User from '../auth/user'; import { IDatabaseAdapter } from '../../types/database'; import Collection from '../../utils/collection'; import { ClassMapType, ClassOptions, ClassId } from '../../types/class'; export default class ClassManager { private database; private classes; constructor(database: IDatabaseAdapter); /** * Get key map from instance * @param classInstance */ private getKeyMapFrom; /** * Connect to the database */ initialize(): Promise; /** * Register classes to data mapper * @param classMap */ register(classMap: ClassMapType): void; /** * Get class from registry * @param className */ get(className: string): C; /** * Find objects * @param query * @param opts */ find(query: Query, opts?: ClassOptions): Promise>; /** * Find the first object that matches * @param query * @param opts */ first(query: Query, opts?: ClassOptions): Promise; /** * Find a single object * @param classType * @param {number|string} id */ getById(classType: C, id: ClassId, include?: string[], select?: string[], opts?: ClassOptions): Promise; /** * Save the object * @param classInstance */ save(classInstance: C, opts?: ClassOptions): Promise; /** * Destroy the object * @param classInstance */ destroy(classInstance: C, opts?: ClassOptions): Promise; /** * Generates a batch loader function * Compatible with the `dataloader` library of Facebook * @param query */ batch(query: Query, opts?: ClassOptions): (ids: number[]) => Promise<(C["prototype"] | null)[]>; }