@mikro-orm/core 7.0.0-dev.153 → 7.0.0-dev.154
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/entity/defineEntity.d.ts +5 -5
- package/index.d.ts +1 -1
- package/metadata/MetadataDiscovery.js +1 -1
- package/metadata/types.d.ts +2 -2
- package/package.json +1 -1
- package/typings.d.ts +10 -2
- package/utils/Utils.js +1 -1
package/entity/defineEntity.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { EntityManager } from '../EntityManager.js';
|
|
2
2
|
import type { ColumnType, PropertyOptions, ReferenceOptions, EnumOptions, EmbeddedOptions, ManyToOneOptions, OneToManyOptions, OneToOneOptions, ManyToManyOptions } from '../metadata/types.js';
|
|
3
|
-
import type { AnyString, GeneratedColumnCallback, Constructor, CheckCallback, FilterQuery, EntityName, Dictionary, EntityMetadata, PrimaryKeyProp, Hidden, Opt, Primary, EntityClass, EntitySchemaWithMeta, InferEntity, MaybeReturnType, Ref, IndexCallback, EntityCtor, IsNever } from '../typings.js';
|
|
3
|
+
import type { AnyString, GeneratedColumnCallback, Constructor, CheckCallback, FilterQuery, EntityName, Dictionary, EntityMetadata, PrimaryKeyProp, Hidden, Opt, Primary, EntityClass, EntitySchemaWithMeta, InferEntity, MaybeReturnType, Ref, IndexCallback, FormulaCallback, EntityCtor, IsNever } from '../typings.js';
|
|
4
4
|
import type { ScalarReference } from './Reference.js';
|
|
5
5
|
import type { SerializeOptions } from '../serialization/EntitySerializer.js';
|
|
6
6
|
import type { Cascade, DeferMode, EmbeddedPrefixMode, EventType, LoadStrategy, QueryOrderMap } from '../enums.js';
|
|
@@ -139,7 +139,7 @@ export declare class UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys
|
|
|
139
139
|
*
|
|
140
140
|
* @see https://mikro-orm.io/docs/defining-entities#formulas Formulas
|
|
141
141
|
*/
|
|
142
|
-
formula<T extends string | (
|
|
142
|
+
formula<T extends string | FormulaCallback<any>>(formula: T): Pick<UniversalPropertyOptionsBuilder<Value, Omit<Options, 'formula'> & {
|
|
143
143
|
formula: T;
|
|
144
144
|
}, IncludeKeys>, IncludeKeys>;
|
|
145
145
|
/**
|
|
@@ -375,7 +375,7 @@ declare const propertyBuilders: {
|
|
|
375
375
|
array: <T = string>(toJsValue?: (i: string) => T, toDbValue?: (i: T) => string) => UniversalPropertyOptionsBuilder<T[], EmptyOptions, IncludeKeysForProperty>;
|
|
376
376
|
decimal: <Mode extends "number" | "string" = "string">(mode?: Mode) => UniversalPropertyOptionsBuilder<NonNullable<Mode extends "number" ? number : string>, EmptyOptions, IncludeKeysForProperty>;
|
|
377
377
|
json: <T>() => UniversalPropertyOptionsBuilder<T, EmptyOptions, IncludeKeysForProperty>;
|
|
378
|
-
formula: <T>(formula: string |
|
|
378
|
+
formula: <T>(formula: string | FormulaCallback<any>) => UniversalPropertyOptionsBuilder<T, EmptyOptions, IncludeKeysForProperty>;
|
|
379
379
|
datetime: (length?: number) => UniversalPropertyOptionsBuilder<Date, EmptyOptions, IncludeKeysForProperty>;
|
|
380
380
|
time: (length?: number) => UniversalPropertyOptionsBuilder<any, EmptyOptions, IncludeKeysForProperty>;
|
|
381
381
|
type: <T extends PropertyValueType>(type: T) => UniversalPropertyOptionsBuilder<InferPropertyValueType<T>, EmptyOptions, IncludeKeysForProperty>;
|
|
@@ -449,7 +449,7 @@ export declare namespace defineEntity {
|
|
|
449
449
|
array: <T = string>(toJsValue?: (i: string) => T, toDbValue?: (i: T) => string) => UniversalPropertyOptionsBuilder<T[], EmptyOptions, IncludeKeysForProperty>;
|
|
450
450
|
decimal: <Mode extends "number" | "string" = "string">(mode?: Mode) => UniversalPropertyOptionsBuilder<NonNullable<Mode extends "number" ? number : string>, EmptyOptions, IncludeKeysForProperty>;
|
|
451
451
|
json: <T>() => UniversalPropertyOptionsBuilder<T, EmptyOptions, IncludeKeysForProperty>;
|
|
452
|
-
formula: <T>(formula: string |
|
|
452
|
+
formula: <T>(formula: string | FormulaCallback<any>) => UniversalPropertyOptionsBuilder<T, EmptyOptions, IncludeKeysForProperty>;
|
|
453
453
|
datetime: (length?: number) => UniversalPropertyOptionsBuilder<Date, EmptyOptions, IncludeKeysForProperty>;
|
|
454
454
|
time: (length?: number) => UniversalPropertyOptionsBuilder<any, EmptyOptions, IncludeKeysForProperty>;
|
|
455
455
|
type: <T extends PropertyValueType>(type: T) => UniversalPropertyOptionsBuilder<InferPropertyValueType<T>, EmptyOptions, IncludeKeysForProperty>;
|
|
@@ -566,7 +566,7 @@ type MaybeOpt<Value, Options> = Options extends {
|
|
|
566
566
|
} ? Opt<Value> : Options extends {
|
|
567
567
|
version: true;
|
|
568
568
|
} ? Opt<Value> : Options extends {
|
|
569
|
-
formula: string | (() => string);
|
|
569
|
+
formula: string | ((...args: any[]) => string);
|
|
570
570
|
} ? Opt<Value> : Value;
|
|
571
571
|
type MaybeHidden<Value, Options> = Options extends {
|
|
572
572
|
hidden: true;
|
package/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* @module core
|
|
4
4
|
*/
|
|
5
5
|
export { EntityMetadata, PrimaryKeyProp, EntityRepositoryType, OptionalProps, EagerProps, HiddenProps, Config } from './typings.js';
|
|
6
|
-
export type { Constructor, ConnectionType, Dictionary, Primary, IPrimaryKey, ObjectQuery, FilterQuery, IWrappedEntity, EntityName, EntityData, Highlighter, MaybePromise, AnyEntity, EntityClass, EntityProperty, QBFilterQuery, PopulateOptions, Populate, Loaded, New, LoadedReference, LoadedCollection, IMigrator, IMigrationGenerator, MigratorEvent, GetRepository, MigrationObject, DeepPartial, PrimaryProperty, Cast, IsUnknown, EntityDictionary, EntityDTO, MigrationDiff, GenerateOptions, FilterObject, IEntityGenerator, ISeedManager, RequiredEntityData, CheckCallback, IndexCallback, SimpleColumnMeta, Rel, Ref, ScalarRef, EntityRef, ISchemaGenerator, UmzugMigration, MigrateOptions, MigrationResult, MigrationRow, EntityKey, EntityValue, EntityDataValue, FilterKey, EntityType, FromEntityType, Selected, IsSubset, NoInfer, EntityProps, ExpandProperty, ExpandScalar, FilterItemValue, ExpandQuery, Scalar, ExpandHint, FilterValue, MergeLoaded, MergeSelected, TypeConfig, AnyString, ClearDatabaseOptions, CreateSchemaOptions, EnsureDatabaseOptions, UpdateSchemaOptions, DropSchemaOptions, RefreshDatabaseOptions, AutoPath, UnboxArray, MetadataProcessor, ImportsResolver, RequiredNullable, DefineConfig, Opt, Hidden, EntitySchemaWithMeta, InferEntity, CheckConstraint, GeneratedColumnCallback, FilterDef, EntityCtor, } from './typings.js';
|
|
6
|
+
export type { Constructor, ConnectionType, Dictionary, Primary, IPrimaryKey, ObjectQuery, FilterQuery, IWrappedEntity, EntityName, EntityData, Highlighter, MaybePromise, AnyEntity, EntityClass, EntityProperty, QBFilterQuery, PopulateOptions, Populate, Loaded, New, LoadedReference, LoadedCollection, IMigrator, IMigrationGenerator, MigratorEvent, GetRepository, MigrationObject, DeepPartial, PrimaryProperty, Cast, IsUnknown, EntityDictionary, EntityDTO, MigrationDiff, GenerateOptions, FilterObject, IEntityGenerator, ISeedManager, RequiredEntityData, CheckCallback, IndexCallback, FormulaCallback, FormulaTable, SimpleColumnMeta, Rel, Ref, ScalarRef, EntityRef, ISchemaGenerator, UmzugMigration, MigrateOptions, MigrationResult, MigrationRow, EntityKey, EntityValue, EntityDataValue, FilterKey, EntityType, FromEntityType, Selected, IsSubset, NoInfer, EntityProps, ExpandProperty, ExpandScalar, FilterItemValue, ExpandQuery, Scalar, ExpandHint, FilterValue, MergeLoaded, MergeSelected, TypeConfig, AnyString, ClearDatabaseOptions, CreateSchemaOptions, EnsureDatabaseOptions, UpdateSchemaOptions, DropSchemaOptions, RefreshDatabaseOptions, AutoPath, UnboxArray, MetadataProcessor, ImportsResolver, RequiredNullable, DefineConfig, Opt, Hidden, EntitySchemaWithMeta, InferEntity, CheckConstraint, GeneratedColumnCallback, FilterDef, EntityCtor, } from './typings.js';
|
|
7
7
|
export * from './enums.js';
|
|
8
8
|
export * from './errors.js';
|
|
9
9
|
export * from './exceptions.js';
|
|
@@ -1241,7 +1241,7 @@ export class MetadataDiscovery {
|
|
|
1241
1241
|
prop.referencedPKs = meta2.primaryKeys;
|
|
1242
1242
|
prop.targetMeta = meta2;
|
|
1243
1243
|
if (!prop.formula && prop.persist === false && [ReferenceKind.MANY_TO_ONE, ReferenceKind.ONE_TO_ONE].includes(prop.kind) && !prop.embedded) {
|
|
1244
|
-
prop.formula =
|
|
1244
|
+
prop.formula = table => `${table}.${this.platform.quoteIdentifier(prop.fieldNames[0])}`;
|
|
1245
1245
|
}
|
|
1246
1246
|
}
|
|
1247
1247
|
initColumnType(prop) {
|
package/metadata/types.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AnyEntity, Constructor, EntityName, AnyString, CheckCallback, GeneratedColumnCallback, FilterQuery, Dictionary, AutoPath, EntityClass, IndexCallback, ObjectQuery } from '../typings.js';
|
|
1
|
+
import type { AnyEntity, Constructor, EntityName, AnyString, CheckCallback, GeneratedColumnCallback, FormulaCallback, FilterQuery, Dictionary, AutoPath, EntityClass, IndexCallback, ObjectQuery } from '../typings.js';
|
|
2
2
|
import type { Cascade, LoadStrategy, DeferMode, QueryOrderMap, EmbeddedPrefixMode } from '../enums.js';
|
|
3
3
|
import type { Type, types } from '../types/index.js';
|
|
4
4
|
import type { EntityManager } from '../EntityManager.js';
|
|
@@ -119,7 +119,7 @@ export interface PropertyOptions<Owner> {
|
|
|
119
119
|
*
|
|
120
120
|
* @see https://mikro-orm.io/docs/defining-entities#formulas Formulas
|
|
121
121
|
*/
|
|
122
|
-
formula?: string |
|
|
122
|
+
formula?: string | FormulaCallback<Owner>;
|
|
123
123
|
/**
|
|
124
124
|
* For generated columns. This will be appended to the column type after the `generated always` clause.
|
|
125
125
|
*/
|
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.154",
|
|
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",
|
package/typings.d.ts
CHANGED
|
@@ -321,7 +321,15 @@ type TableName = {
|
|
|
321
321
|
schema?: string;
|
|
322
322
|
toString: () => string;
|
|
323
323
|
};
|
|
324
|
+
export type FormulaTable = {
|
|
325
|
+
alias: string;
|
|
326
|
+
name: string;
|
|
327
|
+
schema?: string;
|
|
328
|
+
qualifiedName: string;
|
|
329
|
+
toString: () => string;
|
|
330
|
+
};
|
|
324
331
|
export type IndexCallback<T> = (table: TableName, columns: Record<PropertyName<T>, string>, indexName: string) => string | Raw;
|
|
332
|
+
export type FormulaCallback<T> = (table: FormulaTable, columns: Record<PropertyName<T>, string>) => string;
|
|
325
333
|
export type CheckCallback<T> = (columns: Record<PropertyName<T>, string>) => string;
|
|
326
334
|
export type GeneratedColumnCallback<T> = (columns: Record<keyof T, string>) => string;
|
|
327
335
|
export interface CheckConstraint<T = any> {
|
|
@@ -359,7 +367,7 @@ export interface EntityProperty<Owner = any, Target = any> {
|
|
|
359
367
|
fieldNameRaw?: string;
|
|
360
368
|
default?: string | number | boolean | null;
|
|
361
369
|
defaultRaw?: string;
|
|
362
|
-
formula?:
|
|
370
|
+
formula?: FormulaCallback<Owner>;
|
|
363
371
|
filters?: FilterOptions;
|
|
364
372
|
prefix?: string | boolean;
|
|
365
373
|
prefixMode?: EmbeddedPrefixMode;
|
|
@@ -435,7 +443,7 @@ export declare class EntityMetadata<Entity = any, Class extends EntityCtor<Entit
|
|
|
435
443
|
removeProperty(name: string, sync?: boolean): void;
|
|
436
444
|
getPrimaryProps(flatten?: boolean): EntityProperty<Entity>[];
|
|
437
445
|
getPrimaryProp(): EntityProperty<Entity>;
|
|
438
|
-
createColumnMappingObject():
|
|
446
|
+
createColumnMappingObject(): Record<PropertyName<Entity>, string>;
|
|
439
447
|
get tableName(): string;
|
|
440
448
|
set tableName(name: string);
|
|
441
449
|
get uniqueName(): string;
|
package/utils/Utils.js
CHANGED
|
@@ -123,7 +123,7 @@ export function parseJsonSafe(value) {
|
|
|
123
123
|
}
|
|
124
124
|
export class Utils {
|
|
125
125
|
static PK_SEPARATOR = '~~~';
|
|
126
|
-
static #ORM_VERSION = '7.0.0-dev.
|
|
126
|
+
static #ORM_VERSION = '7.0.0-dev.154';
|
|
127
127
|
/**
|
|
128
128
|
* Checks if the argument is instance of `Object`. Returns false for arrays.
|
|
129
129
|
*/
|