@mikro-orm/core 7.0.0-dev.55 → 7.0.0-dev.57
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/EntityManager.d.ts +3 -3
- package/EntityManager.js +0 -19
- package/connections/Connection.d.ts +2 -2
- package/decorators/Transactional.d.ts +2 -1
- package/decorators/Transactional.js +3 -0
- package/drivers/IDatabaseDriver.d.ts +1 -1
- package/enums.d.ts +3 -3
- package/package.json +2 -2
- package/typings.d.ts +6 -2
package/EntityManager.d.ts
CHANGED
|
@@ -109,7 +109,7 @@ export declare class EntityManager<Driver extends IDatabaseDriver = IDatabaseDri
|
|
|
109
109
|
/**
|
|
110
110
|
* Registers global filter to this entity manager. Global filters are enabled by default (unless disabled via last parameter).
|
|
111
111
|
*/
|
|
112
|
-
addFilter<T extends
|
|
112
|
+
addFilter<T extends EntityName<any> | readonly EntityName<any>[]>(options: FilterDef<T>): void;
|
|
113
113
|
/**
|
|
114
114
|
* Sets filter parameter values globally inside context defined by this entity manager.
|
|
115
115
|
* If you want to set shared value for all contexts, be sure to use the root entity manager.
|
|
@@ -129,7 +129,7 @@ export declare class EntityManager<Driver extends IDatabaseDriver = IDatabaseDri
|
|
|
129
129
|
getLoggerContext<T extends Dictionary = Dictionary>(options?: {
|
|
130
130
|
disableContextResolution?: boolean;
|
|
131
131
|
}): T;
|
|
132
|
-
setFlushMode(flushMode?: FlushMode): void;
|
|
132
|
+
setFlushMode(flushMode?: FlushMode | `${FlushMode}`): void;
|
|
133
133
|
protected processWhere<Entity extends object, Hint extends string = never, Fields extends string = '*', Excludes extends string = never>(entityName: string, where: FilterQuery<Entity>, options: FindOptions<Entity, Hint, Fields, Excludes> | FindOneOptions<Entity, Hint, Fields, Excludes>, type: 'read' | 'update' | 'delete'): Promise<FilterQuery<Entity>>;
|
|
134
134
|
protected applyDiscriminatorCondition<Entity extends object>(entityName: string, where: FilterQuery<Entity>): FilterQuery<Entity>;
|
|
135
135
|
protected createPopulateWhere<Entity extends object>(cond: ObjectQuery<Entity>, options: FindOptions<Entity, any, any, any> | FindOneOptions<Entity, any, any, any> | CountOptions<Entity, any>): ObjectQuery<Entity>;
|
|
@@ -611,7 +611,7 @@ export interface ForkOptions {
|
|
|
611
611
|
/** use this flag to ignore the current async context - this is required if we want to call `em.fork()` inside the `getContext` handler */
|
|
612
612
|
disableContextResolution?: boolean;
|
|
613
613
|
/** set flush mode for this fork, overrides the global option can be overridden locally via FindOptions */
|
|
614
|
-
flushMode?: FlushMode
|
|
614
|
+
flushMode?: FlushMode | `${FlushMode}`;
|
|
615
615
|
/** disable transactions for this fork */
|
|
616
616
|
disableTransactions?: boolean;
|
|
617
617
|
/** should we keep the transaction context of the parent EM? */
|
package/EntityManager.js
CHANGED
|
@@ -256,25 +256,6 @@ export class EntityManager {
|
|
|
256
256
|
}
|
|
257
257
|
return { where: options.populateWhere };
|
|
258
258
|
}
|
|
259
|
-
// /**
|
|
260
|
-
// * Registers global filter to this entity manager. Global filters are enabled by default (unless disabled via last parameter).
|
|
261
|
-
// */
|
|
262
|
-
// addFilter<T1>(name: string, cond: FilterQuery<T1> | ((args: Dictionary) => MaybePromise<FilterQuery<T1>>), entityName?: EntityName<T1> | [EntityName<T1>], options?: boolean | Partial<FilterDef>): void;
|
|
263
|
-
//
|
|
264
|
-
// /**
|
|
265
|
-
// * Registers global filter to this entity manager. Global filters are enabled by default (unless disabled via last parameter).
|
|
266
|
-
// */
|
|
267
|
-
// addFilter<T1, T2>(name: string, cond: FilterQuery<T1 | T2> | ((args: Dictionary) => MaybePromise<FilterQuery<T1 | T2>>), entityName?: [EntityName<T1>, EntityName<T2>], options?: boolean | Partial<FilterDef>): void;
|
|
268
|
-
//
|
|
269
|
-
// /**
|
|
270
|
-
// * Registers global filter to this entity manager. Global filters are enabled by default (unless disabled via last parameter).
|
|
271
|
-
// */
|
|
272
|
-
// addFilter<T1, T2, T3>(name: string, cond: FilterQuery<T1 | T2 | T3> | ((args: Dictionary) => MaybePromise<FilterQuery<T1 | T2 | T3>>), entityName?: [EntityName<T1>, EntityName<T2>, EntityName<T3>], options?: boolean | Partial<FilterDef>): void;
|
|
273
|
-
//
|
|
274
|
-
// /**
|
|
275
|
-
// * Registers global filter to this entity manager. Global filters are enabled by default (unless disabled via last parameter).
|
|
276
|
-
// */
|
|
277
|
-
// addFilter(name: string, cond: Dictionary | ((args: Dictionary) => MaybePromise<FilterQuery<AnyEntity>>), entityName?: EntityName<AnyEntity> | EntityName<AnyEntity>[], options?: boolean | Partial<FilterDef>): void;
|
|
278
259
|
/**
|
|
279
260
|
* Registers global filter to this entity manager. Global filters are enabled by default (unless disabled via last parameter).
|
|
280
261
|
*/
|
|
@@ -44,14 +44,14 @@ export declare abstract class Connection {
|
|
|
44
44
|
ensureConnection(): Promise<void>;
|
|
45
45
|
protected onConnect(): Promise<void>;
|
|
46
46
|
transactional<T>(cb: (trx: Transaction) => Promise<T>, options?: {
|
|
47
|
-
isolationLevel?: IsolationLevel
|
|
47
|
+
isolationLevel?: IsolationLevel | `${IsolationLevel}`;
|
|
48
48
|
readOnly?: boolean;
|
|
49
49
|
ctx?: Transaction;
|
|
50
50
|
eventBroadcaster?: TransactionEventBroadcaster;
|
|
51
51
|
loggerContext?: LogContext;
|
|
52
52
|
}): Promise<T>;
|
|
53
53
|
begin(options?: {
|
|
54
|
-
isolationLevel?: IsolationLevel
|
|
54
|
+
isolationLevel?: IsolationLevel | `${IsolationLevel}`;
|
|
55
55
|
readOnly?: boolean;
|
|
56
56
|
ctx?: Transaction;
|
|
57
57
|
eventBroadcaster?: TransactionEventBroadcaster;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type TransactionOptions } from '../enums.js';
|
|
2
2
|
import type { ContextProvider } from '../typings.js';
|
|
3
3
|
type TransactionalOptions<T> = TransactionOptions & {
|
|
4
4
|
context?: ContextProvider<T>;
|
|
@@ -9,6 +9,7 @@ type TransactionalOptions<T> = TransactionOptions & {
|
|
|
9
9
|
* The difference is that you can specify the context in which the transaction begins by providing `context` option,
|
|
10
10
|
* and if omitted, the transaction will begin in the current context implicitly.
|
|
11
11
|
* It works on async functions and can be nested with `em.transactional()`.
|
|
12
|
+
* Unlike `em.transactional()`, this decorator uses `REQUIRED` propagation by default, which means it will join existing transactions.
|
|
12
13
|
*/
|
|
13
14
|
export declare function Transactional<T extends object>(options?: TransactionalOptions<T>): MethodDecorator;
|
|
14
15
|
export {};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { TransactionPropagation } from '../enums.js';
|
|
1
2
|
import { RequestContext } from '../utils/RequestContext.js';
|
|
2
3
|
import { resolveContextProvider } from '../utils/resolveContextProvider.js';
|
|
3
4
|
import { TransactionContext } from '../utils/TransactionContext.js';
|
|
@@ -6,6 +7,7 @@ import { TransactionContext } from '../utils/TransactionContext.js';
|
|
|
6
7
|
* The difference is that you can specify the context in which the transaction begins by providing `context` option,
|
|
7
8
|
* and if omitted, the transaction will begin in the current context implicitly.
|
|
8
9
|
* It works on async functions and can be nested with `em.transactional()`.
|
|
10
|
+
* Unlike `em.transactional()`, this decorator uses `REQUIRED` propagation by default, which means it will join existing transactions.
|
|
9
11
|
*/
|
|
10
12
|
export function Transactional(options = {}) {
|
|
11
13
|
return function (target, propertyKey, descriptor) {
|
|
@@ -15,6 +17,7 @@ export function Transactional(options = {}) {
|
|
|
15
17
|
}
|
|
16
18
|
descriptor.value = async function (...args) {
|
|
17
19
|
const { context, contextName, ...txOptions } = options;
|
|
20
|
+
txOptions.propagation ??= TransactionPropagation.REQUIRED;
|
|
18
21
|
const em = (await resolveContextProvider(this, context))
|
|
19
22
|
|| TransactionContext.getEntityManager(contextName)
|
|
20
23
|
|| RequestContext.getEntityManager(contextName);
|
|
@@ -169,7 +169,7 @@ export interface FindOptions<Entity, Hint extends string = never, Fields extends
|
|
|
169
169
|
export interface FindByCursorOptions<T extends object, P extends string = never, F extends string = '*', E extends string = never, I extends boolean = true> extends Omit<FindOptions<T, P, F, E>, 'limit' | 'offset'> {
|
|
170
170
|
includeCount?: I;
|
|
171
171
|
}
|
|
172
|
-
export interface FindOneOptions<T
|
|
172
|
+
export interface FindOneOptions<T, P extends string = never, F extends string = '*', E extends string = never> extends Omit<FindOptions<T, P, F, E>, 'limit' | 'lockMode'> {
|
|
173
173
|
lockMode?: LockMode;
|
|
174
174
|
lockVersion?: number | Date;
|
|
175
175
|
}
|
package/enums.d.ts
CHANGED
|
@@ -170,11 +170,11 @@ export declare enum TransactionPropagation {
|
|
|
170
170
|
}
|
|
171
171
|
export interface TransactionOptions {
|
|
172
172
|
ctx?: Transaction;
|
|
173
|
-
propagation?: TransactionPropagation
|
|
174
|
-
isolationLevel?: IsolationLevel
|
|
173
|
+
propagation?: TransactionPropagation | `${TransactionPropagation}`;
|
|
174
|
+
isolationLevel?: IsolationLevel | `${IsolationLevel}`;
|
|
175
175
|
readOnly?: boolean;
|
|
176
176
|
clear?: boolean;
|
|
177
|
-
flushMode?: FlushMode
|
|
177
|
+
flushMode?: FlushMode | `${FlushMode}`;
|
|
178
178
|
ignoreNestedTransactions?: boolean;
|
|
179
179
|
loggerContext?: LogContext;
|
|
180
180
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mikro-orm/core",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "7.0.0-dev.
|
|
4
|
+
"version": "7.0.0-dev.57",
|
|
5
5
|
"description": "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.",
|
|
6
6
|
"exports": {
|
|
7
7
|
"./package.json": "./package.json",
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"dataloader": "2.2.3",
|
|
56
56
|
"dotenv": "17.2.3",
|
|
57
57
|
"esprima": "4.0.1",
|
|
58
|
-
"mikro-orm": "7.0.0-dev.
|
|
58
|
+
"mikro-orm": "7.0.0-dev.57",
|
|
59
59
|
"reflect-metadata": "0.2.2",
|
|
60
60
|
"tinyglobby": "0.2.13"
|
|
61
61
|
}
|
package/typings.d.ts
CHANGED
|
@@ -713,14 +713,18 @@ export interface MigrationObject {
|
|
|
713
713
|
name: string;
|
|
714
714
|
class: Constructor<Migration>;
|
|
715
715
|
}
|
|
716
|
-
|
|
716
|
+
type EntityFromInput<T> = T extends readonly EntityName<infer U>[] ? U : T extends EntityName<infer U> ? U : never;
|
|
717
|
+
type FilterDefResolved<T extends object = any> = {
|
|
717
718
|
name: string;
|
|
718
|
-
cond:
|
|
719
|
+
cond: FilterQuery<T> | ((args: Dictionary, type: 'read' | 'update' | 'delete', em: any, options?: FindOptions<T, any, any, any> | FindOneOptions<T, any, any, any>, entityName?: EntityName<T>) => MaybePromise<FilterQuery<T>>);
|
|
719
720
|
default?: boolean;
|
|
720
721
|
entity?: EntityName<T> | EntityName<T>[];
|
|
721
722
|
args?: boolean;
|
|
722
723
|
strict?: boolean;
|
|
723
724
|
};
|
|
725
|
+
export type FilterDef<T extends EntityName<any> | readonly EntityName<any>[] = any> = FilterDefResolved<EntityFromInput<T>> & {
|
|
726
|
+
entity?: T;
|
|
727
|
+
};
|
|
724
728
|
export type Populate<T, P extends string = never> = readonly AutoPath<T, P, `${PopulatePath}`>[] | false;
|
|
725
729
|
export type PopulateOptions<T> = {
|
|
726
730
|
field: EntityKey<T>;
|