UNPKG

@dazejs/framework

Version:

Daze.js - A powerful web framework for Node.js

64 lines (63 loc) 2.59 kB
import { Builder } from '../database/builder'; import { ModelBuilder } from './builder'; import { Model } from './model'; import { HasRelations } from './relations'; declare const inspect: unique symbol; export declare class Repository<TEntity = any> { private exists; private model; private updateAttributeColumns; private withs; needWithTrashed: boolean; needWithSecret: boolean; needAutoTimestap: boolean; constructor(model: Model<TEntity>); getColumns(): IterableIterator<string>; private proxy; isExists(): boolean; setExists(exists?: boolean): this; private hasUpdatedAttributes; private addUpdateAttributeColumn; private getUpdatedAttributes; createQueryBuilder(): ModelBuilder<TEntity> & Builder; getPrimaryValue(): any; fill(data: any): this; getAttributes(): Record<string, any>; setAttribute(key: string, value: any): this; getAttribute(key: string): any; with(relation: string, callback?: (query: ModelBuilder<TEntity> & Builder) => void): this; withTrashed(): this; withSecret(): this; getWiths(): Map<string, { relation: HasRelations; queryCallback?: ((query: ModelBuilder<TEntity> & Builder) => void) | undefined; }>; setWiths(withs: Map<string, any>): this; setWith(relation: string, value: HasRelations, queryCallback?: (query: ModelBuilder<TEntity> & Builder) => void): this; eagerly(withs: Map<string, { relation: HasRelations; queryCallback?: (query: ModelBuilder<TEntity> & Builder) => void; }>, result: Repository): Promise<void>; eagerlyCollection(withs: Map<string, { relation: HasRelations; queryCallback?: (query: ModelBuilder<TEntity> & Builder) => void; }>, results: Repository[]): Promise<void>; delete(): Promise<boolean>; private executeDelete; get(id: number | string): Promise<(Repository<TEntity> & TEntity) | undefined>; save(): Promise<boolean>; private getIntertAttributes; private executeInsertAndSetId; private executeUpdate; create(attributes: Record<string, any>): Promise<Repository<TEntity> & TEntity>; destroy(...ids: (number | string)[]): Promise<number>; toJSON(): Record<string, any>; [inspect](): Record<string, any>; withoutAutoTimestamp(): this; attach(relation: string, ...idsWithDatas: (number | string | { id: number | string; [key: string]: any; })[]): Promise<Repository<TEntity>>; detach(relation: string, ...ids: (number | string)[]): Promise<Repository<TEntity>>; } export {};