// @ts-nocheck import type { FindManyOptions, FindOneOptions, FindOptionsWhere, InsertResult, Repository, SaveOptions, UpdateResult } from 'firedev-typeorm'; import type { QueryDeepPartialEntity } from 'firedev-typeorm/lib/typeorm/query-builder/QueryPartialEntity'; import type { UpsertOptions } from 'firedev-typeorm/lib/typeorm/repository/UpsertOptions'; import type { DataSource as DataSourceType } from 'firedev-typeorm/websql'; import { MySqlQuerySource } from 'firedev-type-sql/websql'; import { BaseInjector } from './base-injector'; export declare abstract class BaseRepository extends BaseInjector { private __entityClassResolveFn; abstract entityClassResolveFn: () => any; constructor(__entityClassResolveFn: () => any); private __dbQuery; get dbQuery(): MySqlQuerySource; get connection(): DataSourceType; private __repository; protected get repository(): Repository; /** * target for repository */ get target(): Function; /** * alias to repository */ protected get repo(): Repository; get repositoryExists(): boolean; __init(context?: any): Promise; /** * Checks if entity has an id. * If entity composite compose ids, it will check them all. */ hasId(entity: Entity): boolean; /** * Gets entity mixed id. */ getId(entity: Entity): any; /** Saves a given entity in the database. * If entity does not exist in the database then inserts, otherwise updates. */ save(item: Entity, options?: SaveOptions & { reload: false; }): Promise; /** * alias to save * -> it will actuall create new entity in db * in oposite to typeorm create method */ create(item: Entity, options?: SaveOptions & { reload: false; }): Promise; bulkSave(items: Entity[], options?: SaveOptions & { reload: false; }): Promise; bulkCreate(items: Entity[], options?: SaveOptions & { reload: false; }): Promise; /** * Saves all given entities in the database. * If entities do not exist in the database then inserts, otherwise updates. */ /** * Merges multiple entities (or entity-like objects) into a given entity. */ merge(mergeIntoEntity: Entity, ...entityLikes: Entity[]): Entity; /** * Creates a new entity from the given plain javascript object. If entity already exist in the database, then * it loads it (and everything related to it), replaces all values with the new ones from the given object * and returns this new entity. This new entity is actually a loaded from the db entity with all properties * replaced from the new object. * * Note that given entity-like object must have an entity id / primary key to find entity by. * Returns undefined if entity with given id was not found. */ preload(entityLike: Entity): Promise; /** * Removes a given entities from the database. */ remove(idOrEntity: number | string | Entity): Promise; /** * alias to remove */ delete(idOrEntity: number | string | Entity): Promise; /** * alias to removeById */ deleteById(id: number | string): Promise; bulkRemove(idsOrEntities: (number | string | Entity)[]): Promise; bulkDelete(ids: (number | string | Entity)[]): Promise; /** * Records the delete date of all given entities. */ softRemove(entities: T[], options: SaveOptions & { reload: false; }): Promise; /** * Records the delete date of all given entities. */ softRemove(entities: T[], options?: SaveOptions): Promise<(T & Entity)[]>; /** * Records the delete date of a given entity. */ softRemove(entity: T, options: SaveOptions & { reload: false; }): Promise; /** * Recovers all given entities in the database. */ recover(entities: T[], options: SaveOptions & { reload: false; }): Promise; /** * Recovers all given entities in the database. */ recover(entities: T[], options?: SaveOptions): Promise<(T & Entity)[]>; /** * Recovers a given entity in the database. */ recover(entity: T, options: SaveOptions & { reload: false; }): Promise; /** * Inserts a given entity into the database. * Unlike save method executes a primitive operation without cascades, relations and other operations included. * Executes fast and efficient INSERT query. * Does not check if entity exist in the database, so query will fail if duplicate entity is being inserted. */ insert(entity: QueryDeepPartialEntity | QueryDeepPartialEntity[]): Promise; update(item: Entity): Promise; updateById(id: number | string, item: Entity): Promise; bulkUpdate(items: Entity[]): Promise<{ models: any[]; }>; /** * Inserts a given entity into the database, unless a unique constraint conflicts then updates the entity * Unlike save method executes a primitive operation without cascades, relations and other operations included. * Executes fast and efficient INSERT ... ON CONFLICT DO UPDATE/ON DUPLICATE KEY UPDATE query. */ upsert(entityOrEntities: QueryDeepPartialEntity | QueryDeepPartialEntity[], conflictPathsOrOptions: string[] | UpsertOptions): Promise; /** * Records the delete date of entities by a given criteria. * Unlike save method executes a primitive operation without cascades, relations and other operations included. * Executes fast and efficient SOFT-DELETE query. * Does not check if entity exist in the database. */ softDelete(criteria: string | string[] | number | number[] | Date | Date[] | FindOptionsWhere): Promise; /** * Restores entities by a given criteria. * Unlike save method executes a primitive operation without cascades, relations and other operations included. * Executes fast and efficient SOFT-DELETE query. * Does not check if entity exist in the database. */ restore(criteria: string | string[] | number | number[] | Date | Date[] | FindOptionsWhere): Promise; /** * Counts entities that match given options. * Useful for pagination. */ count(options?: FindManyOptions): Promise; /** * Counts entities that match given conditions. * Useful for pagination. */ countBy(where: FindOptionsWhere | FindOptionsWhere[]): Promise; /** * Finds entities that match given find options. */ find(options?: FindManyOptions): Promise; /** * Finds entities that match given find options. */ findBy(where: FindOptionsWhere | FindOptionsWhere[]): Promise; /** * Finds entities that match given find options. * Also counts all entities that match given conditions, * but ignores pagination settings (from and take options). */ findAndCount(options?: FindManyOptions): Promise<[Entity[], number]>; /** * Finds entities that match given WHERE conditions. * Also counts all entities that match given conditions, * but ignores pagination settings (from and take options). */ findAndCountBy(where: FindOptionsWhere | FindOptionsWhere[]): Promise<[Entity[], number]>; /** * Finds entities with ids. * Optionally find options or conditions can be applied. * * @deprecated use `findBy` method instead in conjunction with `In` operator, for example: * * .findBy({ * id: In([1, 2, 3]) * }) */ findByIds(ids: any[]): Promise; /** * Finds first entity by a given find options. * If entity was not found in the database - returns null. */ findOne(options: FindOneOptions): Promise; /** * Finds first entity that matches given where condition. * If entity was not found in the database - returns null. */ findOneBy(where: FindOptionsWhere | FindOptionsWhere[]): Promise; /** * Finds first entity that matches given id. * If entity was not found in the database - returns null. * * @deprecated use `findOneBy` method instead in conjunction with `In` operator, for example: * * .findOneBy({ * id: 1 // where "id" is your primary column name * }) */ findOneById(id: number | string | Date): Promise; /** * Finds first entity by a given find options. * If entity was not found in the database - rejects with error. */ findOneOrFail(options: FindOneOptions): Promise; /** * Finds first entity that matches given where condition. * If entity was not found in the database - rejects with error. */ findOneByOrFail(where: FindOptionsWhere | FindOptionsWhere[]): Promise; /** * Executes a raw SQL query and returns a raw database results. * Raw query execution is supported only by relational databases (MongoDB is not supported). */ query(query: string, parameters?: any[]): Promise; /** * Clears all the data from the given table/collection (truncates/drops it). * * Note: this method uses TRUNCATE and may not work as you expect in transactions on some platforms. * @see https://stackoverflow.com/a/5972738/925151 */ clear(): Promise; /** * Increments some column by provided value of the entities matched given conditions. */ increment(conditions: FindOptionsWhere, propertyPath: string, value: number | string): Promise; /** * Decrements some column by provided value of the entities matched given conditions. */ decrement(conditions: FindOptionsWhere, propertyPath: string, value: number | string): Promise; /** * @deprecated use findAndCount instead */ getAll(): Promise<{ models: Entity[]; totalCount: number; }>; getBy(id: number | string): Promise; }