@mikro-orm/core 6.6.5-dev.5 → 6.6.5
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/decorators/Formula.d.ts +2 -2
- package/decorators/Property.d.ts +2 -2
- package/entity/defineEntity.d.ts +5 -5
- package/index.d.ts +1 -1
- package/metadata/MetadataDiscovery.js +1 -1
- package/package.json +2 -2
- package/typings.d.ts +10 -2
package/decorators/Formula.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { AnyEntity } from '../typings';
|
|
1
|
+
import type { AnyEntity, FormulaCallback } from '../typings';
|
|
2
2
|
import type { PropertyOptions } from './Property';
|
|
3
|
-
export declare function Formula<T extends object>(formula: string |
|
|
3
|
+
export declare function Formula<T extends object>(formula: string | FormulaCallback<T>, options?: FormulaOptions<T>): (target: AnyEntity, propertyName: string) => any;
|
|
4
4
|
export interface FormulaOptions<T> extends PropertyOptions<T> {
|
|
5
5
|
}
|
package/decorators/Property.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type Cascade, type LoadStrategy } from '../enums';
|
|
2
|
-
import type { EntityName, Constructor, CheckCallback, GeneratedColumnCallback, AnyString, AnyEntity } from '../typings';
|
|
2
|
+
import type { EntityName, Constructor, CheckCallback, GeneratedColumnCallback, AnyString, AnyEntity, FormulaCallback } from '../typings';
|
|
3
3
|
import type { Type, types } from '../types';
|
|
4
4
|
import type { EntityManager } from '../EntityManager';
|
|
5
5
|
import type { SerializeOptions } from '../serialization/EntitySerializer';
|
|
@@ -88,7 +88,7 @@ export interface PropertyOptions<Owner> {
|
|
|
88
88
|
*
|
|
89
89
|
* @see https://mikro-orm.io/docs/defining-entities#formulas Formulas
|
|
90
90
|
*/
|
|
91
|
-
formula?: string |
|
|
91
|
+
formula?: string | FormulaCallback<Owner>;
|
|
92
92
|
/**
|
|
93
93
|
* For generated columns. This will be appended to the column type after the `generated always` clause.
|
|
94
94
|
*/
|
package/entity/defineEntity.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ import type { ManyToOneOptions } from '../decorators/ManyToOne';
|
|
|
6
6
|
import type { OneToManyOptions } from '../decorators/OneToMany';
|
|
7
7
|
import type { OneToOneOptions } from '../decorators/OneToOne';
|
|
8
8
|
import type { ManyToManyOptions } from '../decorators/ManyToMany';
|
|
9
|
-
import type { AnyString, GeneratedColumnCallback, Constructor, CheckCallback, FilterQuery, EntityName, Dictionary, EntityMetadata, PrimaryKeyProp, Hidden, Opt, Primary, EntityClass, Ref, IndexCallback } from '../typings';
|
|
9
|
+
import type { AnyString, GeneratedColumnCallback, Constructor, CheckCallback, FilterQuery, EntityName, Dictionary, EntityMetadata, PrimaryKeyProp, Hidden, Opt, Primary, EntityClass, Ref, IndexCallback, FormulaCallback } from '../typings';
|
|
10
10
|
import type { ScalarReference } from './Reference';
|
|
11
11
|
import type { SerializeOptions } from '../serialization/EntitySerializer';
|
|
12
12
|
import type { Cascade, DeferMode, EventType, LoadStrategy, QueryOrderMap } from '../enums';
|
|
@@ -142,7 +142,7 @@ export declare class UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys
|
|
|
142
142
|
*
|
|
143
143
|
* @see https://mikro-orm.io/docs/defining-entities#formulas Formulas
|
|
144
144
|
*/
|
|
145
|
-
formula<T extends string | (
|
|
145
|
+
formula<T extends string | FormulaCallback<any>>(formula: T): Pick<UniversalPropertyOptionsBuilder<Value, Omit<Options, 'formula'> & {
|
|
146
146
|
formula: T;
|
|
147
147
|
}, IncludeKeys>, IncludeKeys>;
|
|
148
148
|
/**
|
|
@@ -382,7 +382,7 @@ declare const propertyBuilders: {
|
|
|
382
382
|
array: <T = string>(toJsValue?: (i: string) => T, toDbValue?: (i: T) => string) => UniversalPropertyOptionsBuilder<T[], EmptyOptions, IncludeKeysForProperty>;
|
|
383
383
|
decimal: <Mode extends "number" | "string" = "string">(mode?: Mode) => UniversalPropertyOptionsBuilder<NonNullable<Mode extends "number" ? number : string>, EmptyOptions, IncludeKeysForProperty>;
|
|
384
384
|
json: <T>() => UniversalPropertyOptionsBuilder<T, EmptyOptions, IncludeKeysForProperty>;
|
|
385
|
-
formula: <T>(formula: string |
|
|
385
|
+
formula: <T>(formula: string | FormulaCallback<any>) => UniversalPropertyOptionsBuilder<T, EmptyOptions, IncludeKeysForProperty>;
|
|
386
386
|
datetime: (length?: number) => UniversalPropertyOptionsBuilder<Date, EmptyOptions, IncludeKeysForProperty>;
|
|
387
387
|
time: (length?: number) => UniversalPropertyOptionsBuilder<any, EmptyOptions, IncludeKeysForProperty>;
|
|
388
388
|
type: <T extends PropertyValueType>(type: T) => UniversalPropertyOptionsBuilder<InferPropertyValueType<T>, EmptyOptions, IncludeKeysForProperty>;
|
|
@@ -453,7 +453,7 @@ export declare namespace defineEntity {
|
|
|
453
453
|
array: <T = string>(toJsValue?: (i: string) => T, toDbValue?: (i: T) => string) => UniversalPropertyOptionsBuilder<T[], EmptyOptions, IncludeKeysForProperty>;
|
|
454
454
|
decimal: <Mode extends "number" | "string" = "string">(mode?: Mode) => UniversalPropertyOptionsBuilder<NonNullable<Mode extends "number" ? number : string>, EmptyOptions, IncludeKeysForProperty>;
|
|
455
455
|
json: <T>() => UniversalPropertyOptionsBuilder<T, EmptyOptions, IncludeKeysForProperty>;
|
|
456
|
-
formula: <T>(formula: string |
|
|
456
|
+
formula: <T>(formula: string | FormulaCallback<any>) => UniversalPropertyOptionsBuilder<T, EmptyOptions, IncludeKeysForProperty>;
|
|
457
457
|
datetime: (length?: number) => UniversalPropertyOptionsBuilder<Date, EmptyOptions, IncludeKeysForProperty>;
|
|
458
458
|
time: (length?: number) => UniversalPropertyOptionsBuilder<any, EmptyOptions, IncludeKeysForProperty>;
|
|
459
459
|
type: <T extends PropertyValueType>(type: T) => UniversalPropertyOptionsBuilder<InferPropertyValueType<T>, EmptyOptions, IncludeKeysForProperty>;
|
|
@@ -564,7 +564,7 @@ type MaybeOpt<Value, Options> = Options extends {
|
|
|
564
564
|
} ? Opt<Value> : Options extends {
|
|
565
565
|
version: true;
|
|
566
566
|
} ? Opt<Value> : Options extends {
|
|
567
|
-
formula: string | (() => string);
|
|
567
|
+
formula: string | ((...args: any[]) => string);
|
|
568
568
|
} ? Opt<Value> : Value;
|
|
569
569
|
type MaybeHidden<Value, Options> = Options extends {
|
|
570
570
|
hidden: true;
|
package/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* @packageDocumentation
|
|
3
3
|
* @module core
|
|
4
4
|
*/
|
|
5
|
-
export { Constructor, ConnectionType, Dictionary, PrimaryKeyProp, Primary, IPrimaryKey, ObjectQuery, FilterQuery, IWrappedEntity, EntityName, EntityData, Highlighter, MaybePromise, AnyEntity, EntityClass, EntityProperty, EntityMetadata, QBFilterQuery, PopulateOptions, Populate, Loaded, New, LoadedReference, LoadedCollection, IMigrator, IMigrationGenerator, MigratorEvent, GetRepository, EntityRepositoryType, MigrationObject, DeepPartial, PrimaryProperty, Cast, IsUnknown, EntityDictionary, EntityDTO, MigrationDiff, GenerateOptions, FilterObject, IEntityGenerator, ISeedManager, EntityClassGroup, OptionalProps, EagerProps, HiddenProps, RequiredEntityData, CheckCallback, IndexCallback, SimpleColumnMeta, Rel, Ref, ScalarRef, EntityRef, ISchemaGenerator, UmzugMigration, MigrateOptions, MigrationResult, MigrationRow, EntityKey, EntityValue, EntityDataValue, FilterKey, Opt, EntityType, FromEntityType, Selected, IsSubset, NoInfer, EntityProps, ExpandProperty, ExpandScalar, FilterItemValue, ExpandQuery, Scalar, ExpandHint, Hidden, FilterValue, MergeLoaded, MergeSelected, Config, DefineConfig, TypeConfig, AnyString, ClearDatabaseOptions, CreateSchemaOptions, EnsureDatabaseOptions, UpdateSchemaOptions, DropSchemaOptions, RefreshDatabaseOptions, AutoPath, UnboxArray, MetadataProcessor, ImportsResolver, RequiredNullable, } from './typings';
|
|
5
|
+
export { Constructor, ConnectionType, Dictionary, PrimaryKeyProp, Primary, IPrimaryKey, ObjectQuery, FilterQuery, IWrappedEntity, EntityName, EntityData, Highlighter, MaybePromise, AnyEntity, EntityClass, EntityProperty, EntityMetadata, QBFilterQuery, PopulateOptions, Populate, Loaded, New, LoadedReference, LoadedCollection, IMigrator, IMigrationGenerator, MigratorEvent, GetRepository, EntityRepositoryType, MigrationObject, DeepPartial, PrimaryProperty, Cast, IsUnknown, EntityDictionary, EntityDTO, MigrationDiff, GenerateOptions, FilterObject, IEntityGenerator, ISeedManager, EntityClassGroup, OptionalProps, EagerProps, HiddenProps, RequiredEntityData, CheckCallback, IndexCallback, FormulaCallback, FormulaTable, SimpleColumnMeta, Rel, Ref, ScalarRef, EntityRef, ISchemaGenerator, UmzugMigration, MigrateOptions, MigrationResult, MigrationRow, EntityKey, EntityValue, EntityDataValue, FilterKey, Opt, EntityType, FromEntityType, Selected, IsSubset, NoInfer, EntityProps, ExpandProperty, ExpandScalar, FilterItemValue, ExpandQuery, Scalar, ExpandHint, Hidden, FilterValue, MergeLoaded, MergeSelected, Config, DefineConfig, TypeConfig, AnyString, ClearDatabaseOptions, CreateSchemaOptions, EnsureDatabaseOptions, UpdateSchemaOptions, DropSchemaOptions, RefreshDatabaseOptions, AutoPath, UnboxArray, MetadataProcessor, ImportsResolver, RequiredNullable, } from './typings';
|
|
6
6
|
export * from './enums';
|
|
7
7
|
export * from './errors';
|
|
8
8
|
export * from './exceptions';
|
|
@@ -1268,7 +1268,7 @@ class MetadataDiscovery {
|
|
|
1268
1268
|
prop.referencedPKs = meta2.primaryKeys;
|
|
1269
1269
|
prop.targetMeta = meta2;
|
|
1270
1270
|
if (!prop.formula && prop.persist === false && [enums_1.ReferenceKind.MANY_TO_ONE, enums_1.ReferenceKind.ONE_TO_ONE].includes(prop.kind) && !prop.embedded) {
|
|
1271
|
-
prop.formula =
|
|
1271
|
+
prop.formula = table => `${table}.${this.platform.quoteIdentifier(prop.fieldNames[0])}`;
|
|
1272
1272
|
}
|
|
1273
1273
|
}
|
|
1274
1274
|
initColumnType(prop) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mikro-orm/core",
|
|
3
|
-
"version": "6.6.5
|
|
3
|
+
"version": "6.6.5",
|
|
4
4
|
"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.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"module": "index.mjs",
|
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
"esprima": "4.0.1",
|
|
65
65
|
"fs-extra": "11.3.3",
|
|
66
66
|
"globby": "11.1.0",
|
|
67
|
-
"mikro-orm": "6.6.5
|
|
67
|
+
"mikro-orm": "6.6.5",
|
|
68
68
|
"reflect-metadata": "0.2.2"
|
|
69
69
|
}
|
|
70
70
|
}
|
package/typings.d.ts
CHANGED
|
@@ -313,7 +313,15 @@ type TableName = {
|
|
|
313
313
|
schema?: string;
|
|
314
314
|
toString: () => string;
|
|
315
315
|
};
|
|
316
|
+
export type FormulaTable = {
|
|
317
|
+
alias: string;
|
|
318
|
+
name: string;
|
|
319
|
+
schema?: string;
|
|
320
|
+
qualifiedName: string;
|
|
321
|
+
toString: () => string;
|
|
322
|
+
};
|
|
316
323
|
export type IndexCallback<T> = (table: TableName, columns: Record<PropertyName<T>, string>, indexName: string) => string | RawQueryFragment;
|
|
324
|
+
export type FormulaCallback<T> = (table: FormulaTable, columns: Record<PropertyName<T>, string>) => string;
|
|
317
325
|
export type CheckCallback<T> = (columns: Record<PropertyName<T>, string>) => string;
|
|
318
326
|
export type GeneratedColumnCallback<T> = (columns: Record<keyof T, string>) => string;
|
|
319
327
|
export interface CheckConstraint<T = any> {
|
|
@@ -350,7 +358,7 @@ export interface EntityProperty<Owner = any, Target = any> {
|
|
|
350
358
|
fieldNameRaw?: string;
|
|
351
359
|
default?: string | number | boolean | null;
|
|
352
360
|
defaultRaw?: string;
|
|
353
|
-
formula?:
|
|
361
|
+
formula?: FormulaCallback<Owner>;
|
|
354
362
|
filters?: FilterOptions;
|
|
355
363
|
prefix?: string | boolean;
|
|
356
364
|
prefixMode?: EmbeddedPrefixMode;
|
|
@@ -427,7 +435,7 @@ export declare class EntityMetadata<T = any> {
|
|
|
427
435
|
removeProperty(name: string, sync?: boolean): void;
|
|
428
436
|
getPrimaryProps(flatten?: boolean): EntityProperty<T>[];
|
|
429
437
|
getPrimaryProp(): EntityProperty<T>;
|
|
430
|
-
createColumnMappingObject():
|
|
438
|
+
createColumnMappingObject(): Record<PropertyName<T>, string>;
|
|
431
439
|
get tableName(): string;
|
|
432
440
|
set tableName(name: string);
|
|
433
441
|
sync(initIndexes?: boolean): void;
|