@mikro-orm/core
Version:
TypeScript ORM for Node.js based on Data Mapper, Unit of Work and Identity Map patterns. Supports MongoDB, MySQL, PostgreSQL and SQLite databases as well as usage with vanilla JavaScript.
54 lines (53 loc) • 2.77 kB
TypeScript
import type { MetadataStorage } from '../metadata';
import type { Dictionary, EntityDictionary, EntityMetadata, IHydrator } from '../typings';
import { type EntityFactory, type EntityValidator } from '../entity';
import { type ChangeSet } from './ChangeSet';
import { type Configuration } from '../utils';
import type { DriverMethodOptions, IDatabaseDriver } from '../drivers';
import type { EntityManager } from '../EntityManager';
export declare class ChangeSetPersister {
private readonly driver;
private readonly metadata;
private readonly hydrator;
private readonly factory;
private readonly validator;
private readonly config;
private readonly em;
private readonly platform;
private readonly comparator;
private readonly usesReturningStatement;
constructor(driver: IDatabaseDriver, metadata: MetadataStorage, hydrator: IHydrator, factory: EntityFactory, validator: EntityValidator, config: Configuration, em: EntityManager);
executeInserts<T extends object>(changeSets: ChangeSet<T>[], options?: DriverMethodOptions, withSchema?: boolean): Promise<void>;
executeUpdates<T extends object>(changeSets: ChangeSet<T>[], batched: boolean, options?: DriverMethodOptions, withSchema?: boolean): Promise<void>;
executeDeletes<T extends object>(changeSets: ChangeSet<T>[], options?: DriverMethodOptions, withSchema?: boolean): Promise<void>;
private runForEachSchema;
private processProperties;
private persistNewEntity;
private persistNewEntities;
private prepareOptions;
private persistNewEntitiesBatch;
private persistManagedEntity;
private persistManagedEntities;
private checkConcurrencyKeys;
private persistManagedEntitiesBatch;
private mapPrimaryKey;
/**
* Sets populate flag to new entities so they are serialized like if they were loaded from the db
*/
private markAsPopulated;
private updateEntity;
private checkOptimisticLocks;
private checkOptimisticLock;
/**
* This method also handles reloading of database default values for inserts and raw property updates,
* so we use a single query in case of both versioning and default values is used.
*/
private reloadVersionValues;
private processProperty;
/**
* Maps values returned via `returning` statement (postgres) or the inserted id (other sql drivers).
* No need to handle composite keys here as they need to be set upfront.
* We do need to map to the change set payload too, as it will be used in the originalEntityData for new entities.
*/
mapReturnedValues<T extends object>(entity: T | null | undefined, payload: EntityDictionary<T>, row: Dictionary | undefined, meta: EntityMetadata<T>, upsert?: boolean): void;
}