@mikro-orm/core 7.0.0-dev.4 → 7.0.0-dev.40
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 +84 -18
- package/EntityManager.js +265 -172
- package/MikroORM.d.ts +7 -5
- package/MikroORM.js +0 -1
- package/README.md +3 -2
- package/cache/FileCacheAdapter.d.ts +2 -1
- package/cache/FileCacheAdapter.js +6 -4
- package/connections/Connection.d.ts +4 -2
- package/connections/Connection.js +2 -2
- package/decorators/Check.d.ts +2 -2
- package/decorators/Embeddable.d.ts +5 -5
- package/decorators/Embeddable.js +1 -1
- package/decorators/Embedded.d.ts +6 -12
- package/decorators/Entity.d.ts +18 -3
- package/decorators/Enum.d.ts +1 -1
- package/decorators/Formula.d.ts +1 -2
- package/decorators/Indexed.d.ts +2 -2
- package/decorators/ManyToMany.d.ts +4 -2
- package/decorators/ManyToOne.d.ts +6 -2
- package/decorators/OneToMany.d.ts +4 -4
- package/decorators/OneToOne.d.ts +5 -1
- package/decorators/PrimaryKey.d.ts +2 -3
- package/decorators/Property.d.ts +54 -4
- package/decorators/Transactional.d.ts +1 -0
- package/decorators/Transactional.js +3 -3
- package/decorators/index.d.ts +1 -1
- package/drivers/DatabaseDriver.d.ts +4 -3
- package/drivers/IDatabaseDriver.d.ts +22 -2
- package/entity/ArrayCollection.d.ts +4 -2
- package/entity/ArrayCollection.js +18 -6
- package/entity/Collection.d.ts +1 -2
- package/entity/Collection.js +19 -10
- package/entity/EntityAssigner.d.ts +1 -1
- package/entity/EntityAssigner.js +9 -1
- package/entity/EntityFactory.d.ts +7 -0
- package/entity/EntityFactory.js +29 -9
- package/entity/EntityHelper.js +25 -3
- package/entity/EntityLoader.d.ts +5 -4
- package/entity/EntityLoader.js +74 -37
- package/entity/EntityRepository.d.ts +1 -1
- package/entity/EntityValidator.js +1 -1
- package/entity/Reference.d.ts +9 -7
- package/entity/Reference.js +30 -3
- package/entity/WrappedEntity.js +1 -1
- package/entity/defineEntity.d.ts +561 -0
- package/entity/defineEntity.js +537 -0
- package/entity/index.d.ts +2 -0
- package/entity/index.js +2 -0
- package/entity/utils.d.ts +7 -0
- package/entity/utils.js +15 -3
- package/enums.d.ts +16 -3
- package/enums.js +13 -0
- package/errors.d.ts +6 -0
- package/errors.js +14 -0
- package/events/EventSubscriber.d.ts +3 -1
- package/hydration/ObjectHydrator.d.ts +4 -4
- package/hydration/ObjectHydrator.js +35 -24
- package/index.d.ts +2 -1
- package/index.js +1 -1
- package/logging/DefaultLogger.d.ts +1 -1
- package/logging/SimpleLogger.d.ts +1 -1
- package/metadata/EntitySchema.d.ts +8 -4
- package/metadata/EntitySchema.js +39 -19
- package/metadata/MetadataDiscovery.d.ts +1 -1
- package/metadata/MetadataDiscovery.js +88 -32
- package/metadata/MetadataStorage.js +1 -1
- package/metadata/MetadataValidator.js +4 -3
- package/naming-strategy/AbstractNamingStrategy.d.ts +5 -1
- package/naming-strategy/AbstractNamingStrategy.js +7 -1
- package/naming-strategy/NamingStrategy.d.ts +11 -1
- package/package.json +5 -5
- package/platforms/Platform.d.ts +5 -3
- package/platforms/Platform.js +4 -8
- package/serialization/EntitySerializer.d.ts +2 -0
- package/serialization/EntitySerializer.js +2 -2
- package/serialization/EntityTransformer.js +1 -1
- package/serialization/SerializationContext.js +14 -11
- package/types/BigIntType.d.ts +9 -6
- package/types/BigIntType.js +3 -0
- package/types/BooleanType.d.ts +1 -1
- package/types/DecimalType.d.ts +6 -4
- package/types/DecimalType.js +1 -1
- package/types/DoubleType.js +1 -1
- package/types/JsonType.d.ts +1 -1
- package/types/JsonType.js +7 -2
- package/types/Type.d.ts +2 -1
- package/types/Type.js +1 -1
- package/types/index.d.ts +1 -1
- package/typings.d.ts +88 -39
- package/typings.js +24 -4
- package/unit-of-work/ChangeSetComputer.js +3 -1
- package/unit-of-work/ChangeSetPersister.d.ts +4 -2
- package/unit-of-work/ChangeSetPersister.js +37 -16
- package/unit-of-work/UnitOfWork.d.ts +8 -1
- package/unit-of-work/UnitOfWork.js +109 -41
- package/utils/Configuration.d.ts +23 -5
- package/utils/Configuration.js +17 -3
- package/utils/ConfigurationLoader.d.ts +0 -2
- package/utils/ConfigurationLoader.js +2 -24
- package/utils/Cursor.d.ts +3 -3
- package/utils/Cursor.js +3 -0
- package/utils/DataloaderUtils.d.ts +7 -2
- package/utils/DataloaderUtils.js +38 -7
- package/utils/EntityComparator.d.ts +6 -2
- package/utils/EntityComparator.js +104 -58
- package/utils/QueryHelper.d.ts +9 -1
- package/utils/QueryHelper.js +66 -5
- package/utils/RawQueryFragment.d.ts +36 -2
- package/utils/RawQueryFragment.js +35 -1
- package/utils/TransactionManager.d.ts +65 -0
- package/utils/TransactionManager.js +218 -0
- package/utils/Utils.d.ts +11 -5
- package/utils/Utils.js +76 -33
- package/utils/index.d.ts +1 -0
- package/utils/index.js +1 -0
- package/utils/upsert-utils.d.ts +7 -2
- package/utils/upsert-utils.js +52 -1
package/MikroORM.d.ts
CHANGED
|
@@ -3,13 +3,15 @@ import { type EntitySchema } from './metadata/EntitySchema.js';
|
|
|
3
3
|
import { MetadataStorage } from './metadata/MetadataStorage.js';
|
|
4
4
|
import { Configuration, type Options } from './utils/Configuration.js';
|
|
5
5
|
import type { EntityManager } from './EntityManager.js';
|
|
6
|
-
import type { Constructor, EntityMetadata, EntityName, IEntityGenerator, IMigrator, ISeedManager } from './typings.js';
|
|
6
|
+
import type { AnyEntity, Constructor, EntityClass, EntityClassGroup, EntityMetadata, EntityName, IEntityGenerator, IMigrator, ISeedManager } from './typings.js';
|
|
7
7
|
/**
|
|
8
8
|
* Helper class for bootstrapping the MikroORM.
|
|
9
9
|
*/
|
|
10
|
-
export declare class MikroORM<Driver extends IDatabaseDriver = IDatabaseDriver, EM extends EntityManager = Driver[typeof EntityManagerType] & EntityManager> {
|
|
10
|
+
export declare class MikroORM<Driver extends IDatabaseDriver = IDatabaseDriver, EM extends EntityManager = Driver[typeof EntityManagerType] & EntityManager, Entities extends (string | EntityClass<AnyEntity> | EntityClassGroup<AnyEntity> | EntitySchema)[] = (string | EntityClass<AnyEntity> | EntityClassGroup<AnyEntity> | EntitySchema)[]> {
|
|
11
11
|
/** The global EntityManager instance. If you are using `RequestContext` helper, it will automatically pick the request specific context under the hood */
|
|
12
|
-
em: EM
|
|
12
|
+
em: EM & {
|
|
13
|
+
'~entities'?: Entities;
|
|
14
|
+
};
|
|
13
15
|
readonly driver: Driver;
|
|
14
16
|
readonly config: Configuration<Driver>;
|
|
15
17
|
private metadata;
|
|
@@ -19,7 +21,7 @@ export declare class MikroORM<Driver extends IDatabaseDriver = IDatabaseDriver,
|
|
|
19
21
|
* Initialize the ORM, load entity metadata, create EntityManager and connect to the database.
|
|
20
22
|
* If you omit the `options` parameter, your CLI config will be used.
|
|
21
23
|
*/
|
|
22
|
-
static init<D extends IDatabaseDriver = IDatabaseDriver, EM extends EntityManager = D[typeof EntityManagerType] & EntityManager>(options?: Options<D, EM>): Promise<MikroORM<D, EM>>;
|
|
24
|
+
static init<D extends IDatabaseDriver = IDatabaseDriver, EM extends EntityManager = D[typeof EntityManagerType] & EntityManager, Entities extends (string | EntityClass<AnyEntity> | EntityClassGroup<AnyEntity> | EntitySchema)[] = (string | EntityClass<AnyEntity> | EntityClassGroup<AnyEntity> | EntitySchema)[]>(options?: Options<D, EM, Entities>): Promise<MikroORM<D, EM, Entities>>;
|
|
23
25
|
/**
|
|
24
26
|
* Synchronous variant of the `init` method with some limitations:
|
|
25
27
|
* - database connection will be established when you first interact with the database (or you can use `orm.connect()` explicitly)
|
|
@@ -27,7 +29,7 @@ export declare class MikroORM<Driver extends IDatabaseDriver = IDatabaseDriver,
|
|
|
27
29
|
* - no support for folder based discovery
|
|
28
30
|
* - no check for mismatched package versions
|
|
29
31
|
*/
|
|
30
|
-
static initSync<D extends IDatabaseDriver = IDatabaseDriver, EM extends EntityManager = D[typeof EntityManagerType] & EntityManager>(options: Options<D, EM>): MikroORM<D, EM>;
|
|
32
|
+
static initSync<D extends IDatabaseDriver = IDatabaseDriver, EM extends EntityManager = D[typeof EntityManagerType] & EntityManager, Entities extends (string | EntityClass<AnyEntity> | EntityClassGroup<AnyEntity> | EntitySchema)[] = (string | EntityClass<AnyEntity> | EntityClassGroup<AnyEntity> | EntitySchema)[]>(options: Options<D, EM, Entities>): MikroORM<D, EM, Entities>;
|
|
31
33
|
constructor(options: Options<Driver, EM>);
|
|
32
34
|
/**
|
|
33
35
|
* Connects to the database.
|
package/MikroORM.js
CHANGED
package/README.md
CHANGED
|
@@ -11,7 +11,6 @@ TypeScript ORM for Node.js based on Data Mapper, [Unit of Work](https://mikro-or
|
|
|
11
11
|
[](https://discord.gg/w8bjxFHS7X)
|
|
12
12
|
[](https://www.npmjs.com/package/@mikro-orm/core)
|
|
13
13
|
[](https://coveralls.io/r/mikro-orm/mikro-orm?branch=master)
|
|
14
|
-
[](https://codeclimate.com/github/mikro-orm/mikro-orm/maintainability)
|
|
15
14
|
[](https://github.com/mikro-orm/mikro-orm/actions?workflow=tests)
|
|
16
15
|
|
|
17
16
|
## 🤔 Unit of What?
|
|
@@ -141,7 +140,7 @@ There is also auto-generated [CHANGELOG.md](CHANGELOG.md) file based on commit m
|
|
|
141
140
|
- [Composite and Foreign Keys as Primary Key](https://mikro-orm.io/docs/composite-keys)
|
|
142
141
|
- [Filters](https://mikro-orm.io/docs/filters)
|
|
143
142
|
- [Using `QueryBuilder`](https://mikro-orm.io/docs/query-builder)
|
|
144
|
-
- [
|
|
143
|
+
- [Populating relations](https://mikro-orm.io/docs/populating-relations)
|
|
145
144
|
- [Property Validation](https://mikro-orm.io/docs/property-validation)
|
|
146
145
|
- [Lifecycle Hooks](https://mikro-orm.io/docs/events#hooks)
|
|
147
146
|
- [Vanilla JS Support](https://mikro-orm.io/docs/usage-with-js)
|
|
@@ -382,6 +381,8 @@ See also the list of contributors who [participated](https://github.com/mikro-or
|
|
|
382
381
|
|
|
383
382
|
Please ⭐️ this repository if this project helped you!
|
|
384
383
|
|
|
384
|
+
> If you'd like to support my open-source work, consider sponsoring me directly at [github.com/sponsors/b4nan](https://github.com/sponsors/b4nan).
|
|
385
|
+
|
|
385
386
|
## 📝 License
|
|
386
387
|
|
|
387
388
|
Copyright © 2018 [Martin Adámek](https://github.com/b4nan).
|
|
@@ -3,12 +3,13 @@ export declare class FileCacheAdapter implements SyncCacheAdapter {
|
|
|
3
3
|
private readonly options;
|
|
4
4
|
private readonly baseDir;
|
|
5
5
|
private readonly pretty;
|
|
6
|
+
private readonly hashAlgorithm;
|
|
6
7
|
private readonly VERSION;
|
|
7
8
|
private cache;
|
|
8
9
|
constructor(options: {
|
|
9
10
|
cacheDir: string;
|
|
10
11
|
combined?: boolean | string;
|
|
11
|
-
}, baseDir: string, pretty?: boolean);
|
|
12
|
+
}, baseDir: string, pretty?: boolean, hashAlgorithm?: 'md5' | 'sha256');
|
|
12
13
|
/**
|
|
13
14
|
* @inheritDoc
|
|
14
15
|
*/
|
|
@@ -1,16 +1,18 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { globSync } from 'tinyglobby';
|
|
2
2
|
import { existsSync, readFileSync, writeFileSync, unlinkSync } from 'node:fs';
|
|
3
3
|
import { Utils } from '../utils/Utils.js';
|
|
4
4
|
export class FileCacheAdapter {
|
|
5
5
|
options;
|
|
6
6
|
baseDir;
|
|
7
7
|
pretty;
|
|
8
|
+
hashAlgorithm;
|
|
8
9
|
VERSION = Utils.getORMVersion();
|
|
9
10
|
cache = {};
|
|
10
|
-
constructor(options, baseDir, pretty = false) {
|
|
11
|
+
constructor(options, baseDir, pretty = false, hashAlgorithm = 'md5') {
|
|
11
12
|
this.options = options;
|
|
12
13
|
this.baseDir = baseDir;
|
|
13
14
|
this.pretty = pretty;
|
|
15
|
+
this.hashAlgorithm = hashAlgorithm;
|
|
14
16
|
}
|
|
15
17
|
/**
|
|
16
18
|
* @inheritDoc
|
|
@@ -51,7 +53,7 @@ export class FileCacheAdapter {
|
|
|
51
53
|
*/
|
|
52
54
|
clear() {
|
|
53
55
|
const path = this.path('*');
|
|
54
|
-
const files =
|
|
56
|
+
const files = globSync(path);
|
|
55
57
|
files.forEach(file => unlinkSync(file));
|
|
56
58
|
this.cache = {};
|
|
57
59
|
}
|
|
@@ -77,6 +79,6 @@ export class FileCacheAdapter {
|
|
|
77
79
|
return null;
|
|
78
80
|
}
|
|
79
81
|
const contents = readFileSync(origin);
|
|
80
|
-
return Utils.hash(contents.toString() + this.VERSION);
|
|
82
|
+
return Utils.hash(contents.toString() + this.VERSION, undefined, this.hashAlgorithm);
|
|
81
83
|
}
|
|
82
84
|
}
|
|
@@ -45,15 +45,17 @@ export declare abstract class Connection {
|
|
|
45
45
|
readOnly?: boolean;
|
|
46
46
|
ctx?: Transaction;
|
|
47
47
|
eventBroadcaster?: TransactionEventBroadcaster;
|
|
48
|
+
loggerContext?: LogContext;
|
|
48
49
|
}): Promise<T>;
|
|
49
50
|
begin(options?: {
|
|
50
51
|
isolationLevel?: IsolationLevel;
|
|
51
52
|
readOnly?: boolean;
|
|
52
53
|
ctx?: Transaction;
|
|
53
54
|
eventBroadcaster?: TransactionEventBroadcaster;
|
|
55
|
+
loggerContext?: LogContext;
|
|
54
56
|
}): Promise<Transaction>;
|
|
55
|
-
commit(ctx: Transaction, eventBroadcaster?: TransactionEventBroadcaster): Promise<void>;
|
|
56
|
-
rollback(ctx: Transaction, eventBroadcaster?: TransactionEventBroadcaster): Promise<void>;
|
|
57
|
+
commit(ctx: Transaction, eventBroadcaster?: TransactionEventBroadcaster, loggerContext?: LogContext): Promise<void>;
|
|
58
|
+
rollback(ctx: Transaction, eventBroadcaster?: TransactionEventBroadcaster, loggerContext?: LogContext): Promise<void>;
|
|
57
59
|
abstract execute<T>(query: string, params?: any[], method?: 'all' | 'get' | 'run', ctx?: Transaction): Promise<QueryResult<T> | any | any[]>;
|
|
58
60
|
getConnectionOptions(): ConnectionConfig;
|
|
59
61
|
getClientUrl(): string;
|
|
@@ -46,10 +46,10 @@ export class Connection {
|
|
|
46
46
|
async begin(options) {
|
|
47
47
|
throw new Error(`Transactions are not supported by current driver`);
|
|
48
48
|
}
|
|
49
|
-
async commit(ctx, eventBroadcaster) {
|
|
49
|
+
async commit(ctx, eventBroadcaster, loggerContext) {
|
|
50
50
|
throw new Error(`Transactions are not supported by current driver`);
|
|
51
51
|
}
|
|
52
|
-
async rollback(ctx, eventBroadcaster) {
|
|
52
|
+
async rollback(ctx, eventBroadcaster, loggerContext) {
|
|
53
53
|
throw new Error(`Transactions are not supported by current driver`);
|
|
54
54
|
}
|
|
55
55
|
getConnectionOptions() {
|
package/decorators/Check.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type { CheckConstraint } from '../typings.js';
|
|
2
|
-
export declare function Check<T>(options: CheckOptions<T>): (target:
|
|
1
|
+
import type { CheckConstraint, EntityClass } from '../typings.js';
|
|
2
|
+
export declare function Check<T>(options: CheckOptions<T>): (target: T, propertyName?: T extends EntityClass<unknown> ? undefined : keyof T) => any;
|
|
3
3
|
export type CheckOptions<T = any> = CheckConstraint<T>;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type { Dictionary } from '../typings.js';
|
|
2
|
-
export declare function Embeddable(options?: EmbeddableOptions):
|
|
3
|
-
export
|
|
4
|
-
discriminatorColumn?: string;
|
|
1
|
+
import type { AnyString, Dictionary, EntityClass } from '../typings.js';
|
|
2
|
+
export declare function Embeddable<T>(options?: EmbeddableOptions<T>): (target: T) => T;
|
|
3
|
+
export interface EmbeddableOptions<T> {
|
|
4
|
+
discriminatorColumn?: (T extends EntityClass<infer P> ? keyof P : string) | AnyString;
|
|
5
5
|
discriminatorMap?: Dictionary<string>;
|
|
6
6
|
discriminatorValue?: number | string;
|
|
7
7
|
abstract?: boolean;
|
|
8
|
-
}
|
|
8
|
+
}
|
package/decorators/Embeddable.js
CHANGED
|
@@ -3,7 +3,7 @@ export function Embeddable(options = {}) {
|
|
|
3
3
|
return function (target) {
|
|
4
4
|
const meta = MetadataStorage.getMetadataFromDecorator(target);
|
|
5
5
|
meta.class = target;
|
|
6
|
-
meta.name =
|
|
6
|
+
meta.name = meta.class.name;
|
|
7
7
|
meta.embeddable = true;
|
|
8
8
|
Object.assign(meta, options);
|
|
9
9
|
return target;
|
package/decorators/Embedded.d.ts
CHANGED
|
@@ -1,18 +1,12 @@
|
|
|
1
|
-
import type { AnyEntity } from '../typings.js';
|
|
2
|
-
|
|
1
|
+
import type { AnyEntity, EntityName } from '../typings.js';
|
|
2
|
+
import type { PropertyOptions } from './Property.js';
|
|
3
|
+
export declare function Embedded<Owner extends object, Target>(type?: EmbeddedOptions<Owner, Target> | (() => EntityName<Target> | EntityName<Target>[]), options?: EmbeddedOptions<Owner, Target>): (target: AnyEntity, propertyName: string) => any;
|
|
3
4
|
/** With `absolute` the prefix is set at the root of the entity (regardless of the nesting level) */
|
|
4
5
|
export type EmbeddedPrefixMode = 'absolute' | 'relative';
|
|
5
|
-
export
|
|
6
|
-
entity?: string | (() =>
|
|
7
|
-
type?: string;
|
|
6
|
+
export interface EmbeddedOptions<Owner, Target> extends PropertyOptions<Owner> {
|
|
7
|
+
entity?: string | (() => EntityName<Target> | EntityName<Target>[]);
|
|
8
8
|
prefix?: string | boolean;
|
|
9
9
|
prefixMode?: EmbeddedPrefixMode;
|
|
10
|
-
nullable?: boolean;
|
|
11
10
|
object?: boolean;
|
|
12
11
|
array?: boolean;
|
|
13
|
-
|
|
14
|
-
serializer?: (value: any) => any;
|
|
15
|
-
serializedName?: string;
|
|
16
|
-
groups?: string[];
|
|
17
|
-
persist?: boolean;
|
|
18
|
-
};
|
|
12
|
+
}
|
package/decorators/Entity.d.ts
CHANGED
|
@@ -1,18 +1,33 @@
|
|
|
1
|
-
import type { AnyString, Constructor, Dictionary, EntityClass,
|
|
1
|
+
import type { AnyString, Constructor, Dictionary, EntityClass, ObjectQuery } from '../typings.js';
|
|
2
2
|
import type { FindOptions } from '../drivers/IDatabaseDriver.js';
|
|
3
3
|
export declare function Entity<T extends EntityClass<unknown>>(options?: EntityOptions<T>): (target: T) => void;
|
|
4
|
-
export type EntityOptions<T> = {
|
|
4
|
+
export type EntityOptions<T, E = T extends EntityClass<infer P> ? P : T> = {
|
|
5
|
+
/** Override default collection/table name. Alias for `collection`. */
|
|
5
6
|
tableName?: string;
|
|
7
|
+
/** Sets the schema name. */
|
|
6
8
|
schema?: string;
|
|
9
|
+
/** Override default collection/table name. Alias for `tableName`. */
|
|
7
10
|
collection?: string;
|
|
11
|
+
/** For {@doclink inheritance-mapping#single-table-inheritance | Single Table Inheritance}. */
|
|
8
12
|
discriminatorColumn?: (T extends EntityClass<infer P> ? keyof P : string) | AnyString;
|
|
13
|
+
/** For {@doclink inheritance-mapping#single-table-inheritance | Single Table Inheritance}. */
|
|
9
14
|
discriminatorMap?: Dictionary<string>;
|
|
15
|
+
/** For {@doclink inheritance-mapping#single-table-inheritance | Single Table Inheritance}. */
|
|
10
16
|
discriminatorValue?: number | string;
|
|
17
|
+
/** Enforce use of constructor when creating managed entity instances. */
|
|
11
18
|
forceConstructor?: boolean;
|
|
19
|
+
/** Specify comment to table. (SQL only) */
|
|
12
20
|
comment?: string;
|
|
21
|
+
/** Marks entity as abstract, such entities are inlined during discovery. */
|
|
13
22
|
abstract?: boolean;
|
|
23
|
+
/** Disables change tracking - such entities are ignored during flush. */
|
|
14
24
|
readonly?: boolean;
|
|
25
|
+
/** Marks entity as {@doclink virtual-entities | virtual}. This is set automatically when you use `expression` option. */
|
|
15
26
|
virtual?: boolean;
|
|
16
|
-
|
|
27
|
+
/** Used to make ORM aware of externally defined triggers. This is needed for MS SQL Server multi inserts, ignored in other dialects. */
|
|
28
|
+
hasTriggers?: boolean;
|
|
29
|
+
/** SQL query that maps to a {@doclink virtual-entities | virtual entity}. */
|
|
30
|
+
expression?: string | ((em: any, where: ObjectQuery<E>, options: FindOptions<E, any, any, any>, stream?: boolean) => object);
|
|
31
|
+
/** Set {@doclink repositories#custom-repository | custom repository class}. */
|
|
17
32
|
repository?: () => Constructor;
|
|
18
33
|
};
|
package/decorators/Enum.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { PropertyOptions } from './Property.js';
|
|
2
2
|
import type { AnyEntity, Dictionary } from '../typings.js';
|
|
3
|
-
export declare function Enum<T extends object>(options?: EnumOptions<AnyEntity> | (() => Dictionary)): (target:
|
|
3
|
+
export declare function Enum<T extends object>(options?: EnumOptions<AnyEntity> | (() => Dictionary)): (target: T, propertyName: string) => any;
|
|
4
4
|
export interface EnumOptions<T> extends PropertyOptions<T> {
|
|
5
5
|
items?: (number | string)[] | (() => Dictionary);
|
|
6
6
|
array?: boolean;
|
package/decorators/Formula.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import type { AnyEntity } from '../typings.js';
|
|
2
1
|
import type { PropertyOptions } from './Property.js';
|
|
3
|
-
export declare function Formula<T extends object>(formula: string | ((alias: string) => string), options?: FormulaOptions<T>): (target:
|
|
2
|
+
export declare function Formula<T extends object>(formula: string | ((alias: string) => string), options?: FormulaOptions<T>): (target: T, propertyName: string) => any;
|
|
4
3
|
export interface FormulaOptions<T> extends PropertyOptions<T> {
|
|
5
4
|
}
|
package/decorators/Indexed.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { EntityClass, Dictionary, AutoPath } from '../typings.js';
|
|
1
|
+
import type { EntityClass, Dictionary, AutoPath, IndexCallback } from '../typings.js';
|
|
2
2
|
import type { DeferMode } from '../enums.js';
|
|
3
3
|
export declare function Index<T extends object, H extends string>(options?: IndexOptions<T, H>): (target: T, propertyName?: (T extends EntityClass<unknown> ? undefined : keyof T) | undefined) => any;
|
|
4
4
|
export declare function Unique<T extends object, H extends string>(options?: UniqueOptions<T, H>): (target: T, propertyName?: (T extends EntityClass<unknown> ? undefined : keyof T) | undefined) => any;
|
|
@@ -8,7 +8,7 @@ interface BaseOptions<T, H extends string> {
|
|
|
8
8
|
name?: string;
|
|
9
9
|
properties?: (T extends EntityClass<infer P> ? Properties<P, H> : Properties<T, H>);
|
|
10
10
|
options?: Dictionary;
|
|
11
|
-
expression?: string;
|
|
11
|
+
expression?: string | (T extends EntityClass<infer P> ? IndexCallback<P> : IndexCallback<T>);
|
|
12
12
|
}
|
|
13
13
|
export interface UniqueOptions<T, H extends string = string> extends BaseOptions<T, H> {
|
|
14
14
|
deferMode?: DeferMode | `${DeferMode}`;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { ReferenceOptions } from './Property.js';
|
|
2
|
-
import type { EntityName,
|
|
2
|
+
import type { EntityName, FilterQuery, AnyString } from '../typings.js';
|
|
3
3
|
import { type QueryOrderMap } from '../enums.js';
|
|
4
|
-
export declare function ManyToMany<
|
|
4
|
+
export declare function ManyToMany<Target extends object, Owner extends object>(entity?: ManyToManyOptions<Owner, Target> | string | (() => EntityName<Target>), mappedBy?: (string & keyof Target) | ((e: Target) => any), options?: Partial<ManyToManyOptions<Owner, Target>>): (target: Owner, propertyName: keyof Owner) => any;
|
|
5
5
|
export interface ManyToManyOptions<Owner, Target> extends ReferenceOptions<Owner, Target> {
|
|
6
6
|
/** Set this side as owning. Owning side is where the foreign key is defined. This option is not required if you use `inversedBy` or `mappedBy` to distinguish owning and inverse side. */
|
|
7
7
|
owner?: boolean;
|
|
@@ -37,4 +37,6 @@ export interface ManyToManyOptions<Owner, Target> extends ReferenceOptions<Owner
|
|
|
37
37
|
deleteRule?: 'cascade' | 'no action' | 'set null' | 'set default' | AnyString;
|
|
38
38
|
/** What to do when the reference to the target entity gets updated. */
|
|
39
39
|
updateRule?: 'cascade' | 'no action' | 'set null' | 'set default' | AnyString;
|
|
40
|
+
/** Enable/disable foreign key constraint creation on this relation */
|
|
41
|
+
createForeignKeyConstraint?: boolean;
|
|
40
42
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { ReferenceOptions } from './Property.js';
|
|
2
2
|
import { type DeferMode } from '../enums.js';
|
|
3
|
-
import type {
|
|
4
|
-
export declare function ManyToOne<
|
|
3
|
+
import type { AnyString, EntityName } from '../typings.js';
|
|
4
|
+
export declare function ManyToOne<Target extends object, Owner extends object>(entity?: ManyToOneOptions<Owner, Target> | string | ((e?: any) => EntityName<Target>), options?: Partial<ManyToOneOptions<Owner, Target>>): (target: Owner, propertyName: keyof Owner) => any;
|
|
5
5
|
export interface ManyToOneOptions<Owner, Target> extends ReferenceOptions<Owner, Target> {
|
|
6
6
|
/** Point to the inverse side property name. */
|
|
7
7
|
inversedBy?: (string & keyof Target) | ((e: Target) => any);
|
|
@@ -27,4 +27,8 @@ export interface ManyToOneOptions<Owner, Target> extends ReferenceOptions<Owner,
|
|
|
27
27
|
updateRule?: 'cascade' | 'no action' | 'set null' | 'set default' | AnyString;
|
|
28
28
|
/** Set the constraint type. Immediate constraints are checked for each statement, while deferred ones are only checked at the end of the transaction. Only for postgres unique constraints. */
|
|
29
29
|
deferMode?: DeferMode | `${DeferMode}`;
|
|
30
|
+
/** Enable/disable foreign key constraint creation on this relation */
|
|
31
|
+
createForeignKeyConstraint?: boolean;
|
|
32
|
+
/** Set a custom foreign key constraint name, overriding NamingStrategy.indexName(). */
|
|
33
|
+
foreignKeyName?: string;
|
|
30
34
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { ReferenceOptions } from './Property.js';
|
|
2
2
|
import { ReferenceKind, type QueryOrderMap } from '../enums.js';
|
|
3
|
-
import type { EntityName,
|
|
4
|
-
export declare function createOneToDecorator<Target, Owner>(entity: OneToManyOptions<Owner, Target> | string | ((e?: any) => EntityName<Target>), mappedBy: (string & keyof Target) | ((e: Target) => any) | undefined, options: Partial<OneToManyOptions<Owner, Target>>, kind: ReferenceKind): (target:
|
|
5
|
-
export declare function OneToMany<Target, Owner>(entity: string | ((e?: any) => EntityName<Target>), mappedBy: (string & keyof Target) | ((e: Target) => any), options?: Partial<OneToManyOptions<Owner, Target>>): (target:
|
|
6
|
-
export declare function OneToMany<Target, Owner>(options: OneToManyOptions<Owner, Target>): (target:
|
|
3
|
+
import type { EntityName, FilterQuery } from '../typings.js';
|
|
4
|
+
export declare function createOneToDecorator<Target, Owner>(entity: OneToManyOptions<Owner, Target> | string | ((e?: any) => EntityName<Target>), mappedBy: (string & keyof Target) | ((e: Target) => any) | undefined, options: Partial<OneToManyOptions<Owner, Target>>, kind: ReferenceKind): (target: Owner, propertyName: string) => any;
|
|
5
|
+
export declare function OneToMany<Target, Owner>(entity: string | ((e?: any) => EntityName<Target>), mappedBy: (string & keyof Target) | ((e: Target) => any), options?: Partial<OneToManyOptions<Owner, Target>>): (target: Owner, propertyName: string) => void;
|
|
6
|
+
export declare function OneToMany<Target, Owner>(options: OneToManyOptions<Owner, Target>): (target: Owner, propertyName: string) => void;
|
|
7
7
|
export interface OneToManyOptions<Owner, Target> extends ReferenceOptions<Owner, Target> {
|
|
8
8
|
/** Remove the entity when it gets disconnected from the relationship (see {@doclink cascading | Cascading}). */
|
|
9
9
|
orphanRemoval?: boolean;
|
package/decorators/OneToOne.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type DeferMode } from '../enums.js';
|
|
2
2
|
import { type OneToManyOptions } from './OneToMany.js';
|
|
3
3
|
import type { AnyString, EntityName } from '../typings.js';
|
|
4
|
-
export declare function OneToOne<Target, Owner>(entity?: OneToOneOptions<Owner, Target> | string | ((e: Owner) => EntityName<Target>), mappedByOrOptions?: (string & keyof Target) | ((e: Target) => any) | Partial<OneToOneOptions<Owner, Target>>, options?: Partial<OneToOneOptions<Owner, Target>>): (target:
|
|
4
|
+
export declare function OneToOne<Target, Owner>(entity?: OneToOneOptions<Owner, Target> | string | ((e: Owner) => EntityName<Target>), mappedByOrOptions?: (string & keyof Target) | ((e: Target) => any) | Partial<OneToOneOptions<Owner, Target>>, options?: Partial<OneToOneOptions<Owner, Target>>): (target: Owner, propertyName: string) => any;
|
|
5
5
|
export interface OneToOneOptions<Owner, Target> extends Partial<Omit<OneToManyOptions<Owner, Target>, 'orderBy'>> {
|
|
6
6
|
/** Set this side as owning. Owning side is where the foreign key is defined. This option is not required if you use `inversedBy` or `mappedBy` to distinguish owning and inverse side. */
|
|
7
7
|
owner?: boolean;
|
|
@@ -21,4 +21,8 @@ export interface OneToOneOptions<Owner, Target> extends Partial<Omit<OneToManyOp
|
|
|
21
21
|
updateRule?: 'cascade' | 'no action' | 'set null' | 'set default' | AnyString;
|
|
22
22
|
/** Set the constraint type. Immediate constraints are checked for each statement, while deferred ones are only checked at the end of the transaction. Only for postgres unique constraints. */
|
|
23
23
|
deferMode?: DeferMode | `${DeferMode}`;
|
|
24
|
+
/** Set a custom foreign key constraint name, overriding NamingStrategy.indexName(). */
|
|
25
|
+
foreignKeyName?: string;
|
|
26
|
+
/** Enable/disable foreign key constraint creation on this relation */
|
|
27
|
+
createForeignKeyConstraint?: boolean;
|
|
24
28
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import type { PropertyOptions } from './Property.js';
|
|
2
|
-
|
|
3
|
-
export declare function
|
|
4
|
-
export declare function SerializedPrimaryKey<T extends object>(options?: SerializedPrimaryKeyOptions<T>): (target: AnyEntity, propertyName: string) => any;
|
|
2
|
+
export declare function PrimaryKey<T extends object>(options?: PrimaryKeyOptions<T>): (target: T, propertyName: string) => any;
|
|
3
|
+
export declare function SerializedPrimaryKey<T extends object>(options?: SerializedPrimaryKeyOptions<T>): (target: T, propertyName: string) => any;
|
|
5
4
|
export interface PrimaryKeyOptions<T> extends PropertyOptions<T> {
|
|
6
5
|
}
|
|
7
6
|
export interface SerializedPrimaryKeyOptions<T> extends PropertyOptions<T> {
|
package/decorators/Property.d.ts
CHANGED
|
@@ -3,7 +3,8 @@ import type { EntityName, Constructor, CheckCallback, GeneratedColumnCallback, A
|
|
|
3
3
|
import type { Type, types } from '../types/index.js';
|
|
4
4
|
import type { EntityManager } from '../EntityManager.js';
|
|
5
5
|
import type { SerializeOptions } from '../serialization/EntitySerializer.js';
|
|
6
|
-
|
|
6
|
+
import type { FilterOptions } from '../drivers/IDatabaseDriver.js';
|
|
7
|
+
export declare function Property<T extends object>(options?: PropertyOptions<T>): (target: T, propertyName: string) => any;
|
|
7
8
|
export interface PropertyOptions<Owner> {
|
|
8
9
|
/**
|
|
9
10
|
* Alias for `fieldName`.
|
|
@@ -161,7 +162,7 @@ export interface PropertyOptions<Owner> {
|
|
|
161
162
|
* Set true to define the properties as setter. (virtual)
|
|
162
163
|
*
|
|
163
164
|
* @example
|
|
164
|
-
* ```
|
|
165
|
+
* ```ts
|
|
165
166
|
* @Property({ setter: true })
|
|
166
167
|
* set address(value: string) {
|
|
167
168
|
* this._address = value.toLocaleLowerCase();
|
|
@@ -173,7 +174,7 @@ export interface PropertyOptions<Owner> {
|
|
|
173
174
|
* Set true to define the properties as getter. (virtual)
|
|
174
175
|
*
|
|
175
176
|
* @example
|
|
176
|
-
* ```
|
|
177
|
+
* ```ts
|
|
177
178
|
* @Property({ getter: true })
|
|
178
179
|
* get fullName() {
|
|
179
180
|
* return this.firstName + this.lastName;
|
|
@@ -186,7 +187,7 @@ export interface PropertyOptions<Owner> {
|
|
|
186
187
|
* to the method name.
|
|
187
188
|
*
|
|
188
189
|
* @example
|
|
189
|
-
* ```
|
|
190
|
+
* ```ts
|
|
190
191
|
* @Property({ getter: true })
|
|
191
192
|
* getFullName() {
|
|
192
193
|
* return this.firstName + this.lastName;
|
|
@@ -194,6 +195,53 @@ export interface PropertyOptions<Owner> {
|
|
|
194
195
|
* ```
|
|
195
196
|
*/
|
|
196
197
|
getterName?: keyof Owner;
|
|
198
|
+
/**
|
|
199
|
+
* When using a private property backed by a public get/set pair, use the `accessor` option to point to the other side.
|
|
200
|
+
*
|
|
201
|
+
* > The `fieldName` will be inferred based on the accessor name unless specified explicitly.
|
|
202
|
+
*
|
|
203
|
+
* If the `accessor` option points to something, the ORM will use the backing property directly.
|
|
204
|
+
*
|
|
205
|
+
* @example
|
|
206
|
+
* ```ts
|
|
207
|
+
* @Entity()
|
|
208
|
+
* export class User {
|
|
209
|
+
* // the ORM will use the backing field directly
|
|
210
|
+
* @Property({ accessor: 'email' })
|
|
211
|
+
* private _email: string;
|
|
212
|
+
*
|
|
213
|
+
* get email() {
|
|
214
|
+
* return this._email;
|
|
215
|
+
* }
|
|
216
|
+
*
|
|
217
|
+
* set email() {
|
|
218
|
+
* return this._email;
|
|
219
|
+
* }
|
|
220
|
+
* }
|
|
221
|
+
*```
|
|
222
|
+
*
|
|
223
|
+
* If you want to the ORM to use your accessor internally too, use `accessor: true` on the get/set property instead.
|
|
224
|
+
* This is handy if you want to use a native private property for the backing field.
|
|
225
|
+
*
|
|
226
|
+
* @example
|
|
227
|
+
* ```ts
|
|
228
|
+
* @Entity({ forceConstructor: true })
|
|
229
|
+
* export class User {
|
|
230
|
+
* #email: string;
|
|
231
|
+
*
|
|
232
|
+
* // the ORM will use the accessor internally
|
|
233
|
+
* @Property({ accessor: true })
|
|
234
|
+
* get email() {
|
|
235
|
+
* return this.#email;
|
|
236
|
+
* }
|
|
237
|
+
*
|
|
238
|
+
* set email() {
|
|
239
|
+
* return this.#email;
|
|
240
|
+
* }
|
|
241
|
+
* }
|
|
242
|
+
* ```
|
|
243
|
+
*/
|
|
244
|
+
accessor?: keyof Owner | AnyString | boolean;
|
|
197
245
|
/**
|
|
198
246
|
* Set to define serialized primary key for MongoDB. (virtual)
|
|
199
247
|
* Alias for `@SerializedPrimaryKey()` decorator.
|
|
@@ -242,6 +290,8 @@ export interface ReferenceOptions<Owner, Target> extends PropertyOptions<Owner>
|
|
|
242
290
|
eager?: boolean;
|
|
243
291
|
/** Override the default loading strategy for this property. This option has precedence over the global `loadStrategy`, but can be overridden by `FindOptions.strategy`. */
|
|
244
292
|
strategy?: LoadStrategy | `${LoadStrategy}`;
|
|
293
|
+
/** Control filter parameters for the relation. This will serve as a default value when processing filters on this relation. It's value can be overridden via `em.fork()` or `FindOptions`. */
|
|
294
|
+
filters?: FilterOptions;
|
|
245
295
|
}
|
|
246
296
|
/**
|
|
247
297
|
* Inspired by https://github.com/typeorm/typeorm/blob/941b584ba135617e55d6685caef671172ec1dc03/src/driver/types/ColumnTypes.ts
|
|
@@ -2,6 +2,7 @@ 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>;
|
|
5
|
+
contextName?: string;
|
|
5
6
|
};
|
|
6
7
|
/**
|
|
7
8
|
* This decorator wraps the method with `em.transactional()`, so you can provide `TransactionOptions` just like with `em.transactional()`.
|
|
@@ -14,10 +14,10 @@ export function Transactional(options = {}) {
|
|
|
14
14
|
throw new Error('@Transactional() should be use with async functions');
|
|
15
15
|
}
|
|
16
16
|
descriptor.value = async function (...args) {
|
|
17
|
-
const { context, ...txOptions } = options;
|
|
17
|
+
const { context, contextName, ...txOptions } = options;
|
|
18
18
|
const em = (await resolveContextProvider(this, context))
|
|
19
|
-
|| TransactionContext.getEntityManager()
|
|
20
|
-
|| RequestContext.getEntityManager();
|
|
19
|
+
|| TransactionContext.getEntityManager(contextName)
|
|
20
|
+
|| RequestContext.getEntityManager(contextName);
|
|
21
21
|
if (!em) {
|
|
22
22
|
throw new Error(`@Transactional() decorator can only be applied to methods of classes with \`orm: MikroORM\` property, \`em: EntityManager\` property, or with a callback parameter like \`@Transactional(() => orm)\` that returns one of those types. The parameter will contain a reference to current \`this\`. Returning an EntityRepository from it is also supported.`);
|
|
23
23
|
}
|
package/decorators/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ export * from './Entity.js';
|
|
|
3
3
|
export * from './OneToOne.js';
|
|
4
4
|
export * from './ManyToOne.js';
|
|
5
5
|
export * from './ManyToMany.js';
|
|
6
|
-
export { OneToMany, OneToManyOptions } from './OneToMany.js';
|
|
6
|
+
export { OneToMany, type OneToManyOptions } from './OneToMany.js';
|
|
7
7
|
export * from './Property.js';
|
|
8
8
|
export * from './Check.js';
|
|
9
9
|
export * from './Enum.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { type CountOptions, type DeleteOptions, type DriverMethodOptions, EntityManagerType, type FindOneOptions, type FindOptions, type IDatabaseDriver, type LockOptions, type NativeInsertUpdateManyOptions, type NativeInsertUpdateOptions, type OrderDefinition } from './IDatabaseDriver.js';
|
|
2
|
-
import type { ConnectionType, Dictionary, EntityData, EntityDictionary, EntityMetadata, EntityProperty, FilterQuery, PopulateOptions, Primary } from '../typings.js';
|
|
1
|
+
import { type CountOptions, type DeleteOptions, type DriverMethodOptions, EntityManagerType, type FindOneOptions, type FindOptions, type IDatabaseDriver, type LockOptions, type NativeInsertUpdateManyOptions, type NativeInsertUpdateOptions, type OrderDefinition, type StreamOptions } from './IDatabaseDriver.js';
|
|
2
|
+
import type { ConnectionType, Dictionary, EntityData, EntityDictionary, EntityMetadata, EntityName, EntityProperty, FilterQuery, PopulateOptions, Primary } from '../typings.js';
|
|
3
3
|
import type { MetadataStorage } from '../metadata/MetadataStorage.js';
|
|
4
4
|
import type { Connection, QueryResult, Transaction } from '../connections/Connection.js';
|
|
5
5
|
import { type Configuration, type ConnectionOptions } from '../utils/Configuration.js';
|
|
@@ -30,7 +30,7 @@ export declare abstract class DatabaseDriver<C extends Connection> implements ID
|
|
|
30
30
|
abstract nativeDelete<T extends object>(entityName: string, where: FilterQuery<T>, options?: DeleteOptions<T>): Promise<QueryResult<T>>;
|
|
31
31
|
abstract count<T extends object, P extends string = never>(entityName: string, where: FilterQuery<T>, options?: CountOptions<T, P>): Promise<number>;
|
|
32
32
|
createEntityManager(useContext?: boolean): this[typeof EntityManagerType];
|
|
33
|
-
findVirtual<T extends object>(entityName:
|
|
33
|
+
findVirtual<T extends object>(entityName: EntityName<T>, where: FilterQuery<T>, options: FindOptions<T, any, any, any>): Promise<EntityData<T>[]>;
|
|
34
34
|
countVirtual<T extends object>(entityName: string, where: FilterQuery<T>, options: CountOptions<T, any>): Promise<number>;
|
|
35
35
|
aggregate(entityName: string, pipeline: any[]): Promise<any[]>;
|
|
36
36
|
loadFromPivotTable<T extends object, O extends object>(prop: EntityProperty, owners: Primary<O>[][], where?: FilterQuery<any>, orderBy?: OrderDefinition<T>, ctx?: Transaction, options?: FindOptions<T, any, any, any>, pivotJoin?: boolean): Promise<Dictionary<T[]>>;
|
|
@@ -55,6 +55,7 @@ export declare abstract class DatabaseDriver<C extends Connection> implements ID
|
|
|
55
55
|
protected getPrimaryKeyFields(entityName: string): string[];
|
|
56
56
|
protected createReplicas(cb: (c: ConnectionOptions) => C): C[];
|
|
57
57
|
lockPessimistic<T extends object>(entity: T, options: LockOptions): Promise<void>;
|
|
58
|
+
abstract stream<T extends object>(entityName: EntityName<T>, where: FilterQuery<T>, options: StreamOptions<T>): AsyncIterableIterator<T>;
|
|
58
59
|
/**
|
|
59
60
|
* @inheritDoc
|
|
60
61
|
*/
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ConnectionType, EntityData, EntityMetadata, EntityProperty, FilterQuery, Primary, Dictionary, QBFilterQuery, IPrimaryKey, PopulateOptions, EntityDictionary, AutoPath, ObjectQuery, FilterObject, Populate } from '../typings.js';
|
|
1
|
+
import type { ConnectionType, EntityData, EntityMetadata, EntityProperty, FilterQuery, Primary, Dictionary, QBFilterQuery, IPrimaryKey, PopulateOptions, EntityDictionary, AutoPath, ObjectQuery, FilterObject, Populate, EntityName } from '../typings.js';
|
|
2
2
|
import type { Connection, QueryResult, Transaction } from '../connections/Connection.js';
|
|
3
3
|
import type { FlushMode, LockMode, QueryOrderMap, QueryFlag, LoadStrategy, PopulateHint, PopulatePath } from '../enums.js';
|
|
4
4
|
import type { Platform } from '../platforms/Platform.js';
|
|
@@ -27,6 +27,7 @@ export interface IDatabaseDriver<C extends Connection = Connection> {
|
|
|
27
27
|
*/
|
|
28
28
|
findOne<T extends object, P extends string = never, F extends string = '*', E extends string = never>(entityName: string, where: FilterQuery<T>, options?: FindOneOptions<T, P, F, E>): Promise<EntityData<T> | null>;
|
|
29
29
|
findVirtual<T extends object>(entityName: string, where: FilterQuery<T>, options: FindOptions<T, any, any, any>): Promise<EntityData<T>[]>;
|
|
30
|
+
stream<T extends object>(entityName: EntityName<T>, where: FilterQuery<T>, options: StreamOptions<T>): AsyncIterableIterator<T>;
|
|
30
31
|
nativeInsert<T extends object>(entityName: string, data: EntityDictionary<T>, options?: NativeInsertUpdateOptions<T>): Promise<QueryResult<T>>;
|
|
31
32
|
nativeInsertMany<T extends object>(entityName: string, data: EntityDictionary<T>[], options?: NativeInsertUpdateManyOptions<T>, transform?: (sql: string) => string): Promise<QueryResult<T>>;
|
|
32
33
|
nativeUpdate<T extends object>(entityName: string, where: FilterQuery<T>, data: EntityDictionary<T>, options?: NativeInsertUpdateOptions<T>): Promise<QueryResult<T>>;
|
|
@@ -68,6 +69,18 @@ export type OrderDefinition<T> = (QueryOrderMap<T> & {
|
|
|
68
69
|
export interface FindAllOptions<T, P extends string = never, F extends string = '*', E extends string = never> extends FindOptions<T, P, F, E> {
|
|
69
70
|
where?: FilterQuery<T>;
|
|
70
71
|
}
|
|
72
|
+
export interface StreamOptions<Entity, Populate extends string = never, Fields extends string = '*', Exclude extends string = never> extends Omit<FindAllOptions<Entity, Populate, Fields, Exclude>, 'cache' | 'before' | 'after' | 'first' | 'last' | 'overfetch' | 'strategy'> {
|
|
73
|
+
/**
|
|
74
|
+
* When populating to-many relations, the ORM streams fully merged entities instead of yielding every row.
|
|
75
|
+
* You can opt out of this behavior by specifying `mergeResults: false`. This will yield every row from
|
|
76
|
+
* the SQL result, but still mapped to entities, meaning that to-many collections will contain at most
|
|
77
|
+
* a single item, and you will get duplicate root entities when they have multiple items in the populated
|
|
78
|
+
* collection.
|
|
79
|
+
*
|
|
80
|
+
* @default true
|
|
81
|
+
*/
|
|
82
|
+
mergeResults?: boolean;
|
|
83
|
+
}
|
|
71
84
|
export type FilterOptions = Dictionary<boolean | Dictionary> | string[] | boolean;
|
|
72
85
|
export interface LoadHint<Entity, Hint extends string = never, Fields extends string = PopulatePath.ALL, Excludes extends string = never> {
|
|
73
86
|
populate?: Populate<Entity, Hint>;
|
|
@@ -146,8 +159,11 @@ export interface FindOptions<Entity, Hint extends string = never, Fields extends
|
|
|
146
159
|
hintComments?: string | string[];
|
|
147
160
|
loggerContext?: LogContext;
|
|
148
161
|
logging?: LoggingOptions;
|
|
162
|
+
/** @internal used to apply filters to the auto-joined relations */
|
|
163
|
+
em?: EntityManager;
|
|
149
164
|
}
|
|
150
|
-
export interface FindByCursorOptions<T extends object, P extends string = never, F extends string = '*', E extends string = never> extends Omit<FindOptions<T, P, F, E>, 'limit' | 'offset'> {
|
|
165
|
+
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'> {
|
|
166
|
+
includeCount?: I;
|
|
151
167
|
}
|
|
152
168
|
export interface FindOneOptions<T extends object, P extends string = never, F extends string = '*', E extends string = never> extends Omit<FindOptions<T, P, F, E>, 'limit' | 'lockMode'> {
|
|
153
169
|
lockMode?: LockMode;
|
|
@@ -163,6 +179,7 @@ export interface NativeInsertUpdateOptions<T> {
|
|
|
163
179
|
schema?: string;
|
|
164
180
|
/** `nativeUpdate()` only option */
|
|
165
181
|
upsert?: boolean;
|
|
182
|
+
loggerContext?: LogContext;
|
|
166
183
|
}
|
|
167
184
|
export interface NativeInsertUpdateManyOptions<T> extends NativeInsertUpdateOptions<T> {
|
|
168
185
|
processCollections?: boolean;
|
|
@@ -197,6 +214,8 @@ export interface CountOptions<T extends object, P extends string = never> {
|
|
|
197
214
|
hintComments?: string | string[];
|
|
198
215
|
loggerContext?: LogContext;
|
|
199
216
|
logging?: LoggingOptions;
|
|
217
|
+
/** @internal used to apply filters to the auto-joined relations */
|
|
218
|
+
em?: EntityManager;
|
|
200
219
|
}
|
|
201
220
|
export interface UpdateOptions<T> {
|
|
202
221
|
filters?: FilterOptions;
|
|
@@ -218,6 +237,7 @@ export interface LockOptions extends DriverMethodOptions {
|
|
|
218
237
|
export interface DriverMethodOptions {
|
|
219
238
|
ctx?: Transaction;
|
|
220
239
|
schema?: string;
|
|
240
|
+
loggerContext?: LogContext;
|
|
221
241
|
}
|
|
222
242
|
export interface GetReferenceOptions {
|
|
223
243
|
wrapped?: boolean;
|