mirror of
https://github.com/typeorm/typeorm.git
synced 2025-12-08 21:26:23 +00:00
removed reflect metadata
This commit is contained in:
parent
ae7b362560
commit
43d90f4a0b
@ -1,4 +1,3 @@
|
||||
import "reflect-metadata";
|
||||
import {NamingStrategyMetadata} from "../metadata/NamingStrategyMetadata";
|
||||
import {defaultMetadataStorage} from "../typeorm";
|
||||
|
||||
|
||||
@ -4,7 +4,6 @@ import {AutoIncrementOnlyForPrimaryError} from "../error/AutoIncrementOnlyForPri
|
||||
import {defaultMetadataStorage} from "../../typeorm";
|
||||
import {ColumnMetadata} from "../../metadata/ColumnMetadata";
|
||||
import {ColumnType, ColumnTypes} from "../../metadata/types/ColumnTypes";
|
||||
import "reflect-metadata";
|
||||
|
||||
/**
|
||||
* Column decorator is used to mark a specific class property as a table column. Only properties decorated with this
|
||||
@ -32,11 +31,11 @@ export function Column(typeOrOptions?: ColumnType|ColumnOptions, options?: Colum
|
||||
return function (object: Object, propertyName: string) {
|
||||
|
||||
// todo: need to store not string type, but original type instead? (like in relation metadata)
|
||||
const reflectedType = ColumnTypes.typeToString(Reflect.getMetadata("design:type", object, propertyName));
|
||||
const reflectedType = ColumnTypes.typeToString((<any> Reflect).getMetadata("design:type", object, propertyName));
|
||||
|
||||
// if type is not given implicitly then try to guess it
|
||||
if (!type)
|
||||
type = ColumnTypes.determineTypeFromFunction(Reflect.getMetadata("design:type", object, propertyName));
|
||||
type = ColumnTypes.determineTypeFromFunction((<any> Reflect).getMetadata("design:type", object, propertyName));
|
||||
|
||||
// if column options are not given then create a new empty options
|
||||
if (!options) options = {} as ColumnOptions;
|
||||
|
||||
@ -2,7 +2,6 @@ import {ColumnOptions} from "../../metadata/options/ColumnOptions";
|
||||
import {ColumnType, ColumnTypes} from "../../metadata/types/ColumnTypes";
|
||||
import {defaultMetadataStorage} from "../../typeorm";
|
||||
import {ColumnMetadata} from "../../metadata/ColumnMetadata";
|
||||
import "reflect-metadata";
|
||||
|
||||
/**
|
||||
* This column will store a creation date of the inserted object. Creation date is generated and inserted only once,
|
||||
@ -11,7 +10,7 @@ import "reflect-metadata";
|
||||
export function CreateDateColumn(options?: ColumnOptions): Function {
|
||||
return function (object: Object, propertyName: string) {
|
||||
|
||||
const reflectedType = ColumnTypes.typeToString(Reflect.getMetadata("design:type", object, propertyName));
|
||||
const reflectedType = ColumnTypes.typeToString((<any> Reflect).getMetadata("design:type", object, propertyName));
|
||||
|
||||
// if column options are not given then create a new empty options
|
||||
if (!options) options = {} as ColumnOptions;
|
||||
|
||||
@ -4,7 +4,6 @@ import {ColumnTypeUndefinedError} from "../error/ColumnTypeUndefinedError";
|
||||
import {defaultMetadataStorage} from "../../typeorm";
|
||||
import {ColumnMetadata} from "../../metadata/ColumnMetadata";
|
||||
import {PrimaryColumnCannotBeNullableError} from "../error/PrimaryColumnCannotBeNullableError";
|
||||
import "reflect-metadata";
|
||||
|
||||
/**
|
||||
* Column decorator is used to mark a specific class property as a table column. Only properties decorated with this
|
||||
@ -34,11 +33,11 @@ export function PrimaryColumn(typeOrOptions?: ColumnType|ColumnOptions, options?
|
||||
}
|
||||
return function (object: Object, propertyName: string) {
|
||||
|
||||
const reflectedType = ColumnTypes.typeToString(Reflect.getMetadata("design:type", object, propertyName));
|
||||
const reflectedType = ColumnTypes.typeToString((<any> Reflect).getMetadata("design:type", object, propertyName));
|
||||
|
||||
// if type is not given implicitly then try to guess it
|
||||
if (!type)
|
||||
type = ColumnTypes.determineTypeFromFunction(Reflect.getMetadata("design:type", object, propertyName));
|
||||
type = ColumnTypes.determineTypeFromFunction((<any> Reflect).getMetadata("design:type", object, propertyName));
|
||||
|
||||
// if column options are not given then create a new empty options
|
||||
if (!options) options = {} as ColumnOptions;
|
||||
|
||||
@ -8,7 +8,7 @@ export function RelationsCountColumn<T>(relation: string|((object: T) => any)):
|
||||
return function (object: Object, propertyName: string) {
|
||||
|
||||
// todo: need to check if property type is number?
|
||||
// const reflectedType = ColumnTypes.typeToString(Reflect.getMetadata("design:type", object, propertyName));
|
||||
// const reflectedType = ColumnTypes.typeToString((<any> Reflect).getMetadata("design:type", object, propertyName));
|
||||
|
||||
// create and register a new column metadata
|
||||
defaultMetadataStorage().relationCountMetadatas.add(new RelationsCountMetadata(object.constructor, propertyName, relation));
|
||||
|
||||
@ -2,7 +2,6 @@ import {ColumnOptions} from "../../metadata/options/ColumnOptions";
|
||||
import {ColumnTypes} from "../../metadata/types/ColumnTypes";
|
||||
import {defaultMetadataStorage} from "../../typeorm";
|
||||
import {ColumnMetadata} from "../../metadata/ColumnMetadata";
|
||||
import "reflect-metadata";
|
||||
|
||||
/**
|
||||
* This column will store an update date of the updated object. This date is being updated each time you persist the
|
||||
@ -11,7 +10,7 @@ import "reflect-metadata";
|
||||
export function UpdateDateColumn(options?: ColumnOptions): Function {
|
||||
return function (object: Object, propertyName: string) {
|
||||
|
||||
const reflectedType = ColumnTypes.typeToString(Reflect.getMetadata("design:type", object, propertyName));
|
||||
const reflectedType = ColumnTypes.typeToString((<any> Reflect).getMetadata("design:type", object, propertyName));
|
||||
|
||||
// if column options are not given then create a new empty options
|
||||
if (!options) options = {} as ColumnOptions;
|
||||
|
||||
@ -2,7 +2,6 @@ import {ColumnOptions} from "../../metadata/options/ColumnOptions";
|
||||
import {ColumnTypes} from "../../metadata/types/ColumnTypes";
|
||||
import {defaultMetadataStorage} from "../../typeorm";
|
||||
import {ColumnMetadata} from "../../metadata/ColumnMetadata";
|
||||
import "reflect-metadata";
|
||||
|
||||
/**
|
||||
* This column will store a number - version of the entity. Every time your entity will be persisted, this number will
|
||||
@ -11,7 +10,7 @@ import "reflect-metadata";
|
||||
export function VersionColumn(options?: ColumnOptions): Function {
|
||||
return function (object: Object, propertyName: string) {
|
||||
|
||||
const reflectedType = ColumnTypes.typeToString(Reflect.getMetadata("design:type", object, propertyName));
|
||||
const reflectedType = ColumnTypes.typeToString((<any> Reflect).getMetadata("design:type", object, propertyName));
|
||||
|
||||
// if column options are not given then create a new empty options
|
||||
if (!options) options = {} as ColumnOptions;
|
||||
|
||||
@ -38,7 +38,7 @@ export function ManyToMany<T>(typeFunction: (type?: any) => ConstructorFunction<
|
||||
return function (object: Object, propertyName: string) {
|
||||
if (!options) options = {} as RelationOptions;
|
||||
|
||||
const reflectedType = Reflect.getMetadata("design:type", object, propertyName);
|
||||
const reflectedType = (<any> Reflect).getMetadata("design:type", object, propertyName);
|
||||
|
||||
defaultMetadataStorage().relationMetadatas.add(new RelationMetadata({
|
||||
target: object.constructor,
|
||||
|
||||
@ -38,7 +38,7 @@ export function ManyToOne<T>(typeFunction: (type?: any) => ConstructorFunction<T
|
||||
return function (object: Object, propertyName: string) {
|
||||
if (!options) options = {} as RelationOptions;
|
||||
|
||||
const reflectedType = Reflect.getMetadata("design:type", object, propertyName);
|
||||
const reflectedType = (<any> Reflect).getMetadata("design:type", object, propertyName);
|
||||
|
||||
defaultMetadataStorage().relationMetadatas.add(new RelationMetadata({
|
||||
target: object.constructor,
|
||||
|
||||
@ -40,7 +40,7 @@ export function OneToMany<T>(typeFunction: (type?: any) => ConstructorFunction<T
|
||||
return function (object: Object, propertyName: string) {
|
||||
if (!options) options = {} as RelationOptions;
|
||||
|
||||
const reflectedType = Reflect.getMetadata("design:type", object, propertyName);
|
||||
const reflectedType = (<any> Reflect).getMetadata("design:type", object, propertyName);
|
||||
|
||||
defaultMetadataStorage().relationMetadatas.add(new RelationMetadata({
|
||||
target: object.constructor,
|
||||
|
||||
@ -35,7 +35,7 @@ export function OneToOne<T>(typeFunction: (type?: any) => ConstructorFunction<T>
|
||||
return function (object: Object, propertyName: string) {
|
||||
if (!options) options = {} as RelationOptions;
|
||||
|
||||
const reflectedType = Reflect.getMetadata("design:type", object, propertyName);
|
||||
const reflectedType = (<any> Reflect).getMetadata("design:type", object, propertyName);
|
||||
|
||||
defaultMetadataStorage().relationMetadatas.add(new RelationMetadata({
|
||||
target: object.constructor,
|
||||
|
||||
@ -10,7 +10,7 @@ export function TreeChildren(options?: RelationOptions): Function {
|
||||
return function (object: Object, propertyName: string) {
|
||||
if (!options) options = {} as RelationOptions;
|
||||
|
||||
const reflectedType = Reflect.getMetadata("design:type", object, propertyName);
|
||||
const reflectedType = (<any> Reflect).getMetadata("design:type", object, propertyName);
|
||||
|
||||
// add one-to-many relation for this
|
||||
defaultMetadataStorage().relationMetadatas.add(new RelationMetadata({
|
||||
|
||||
@ -9,7 +9,7 @@ import {ColumnMetadata} from "../../metadata/ColumnMetadata";
|
||||
export function TreeLevelColumn(): Function {
|
||||
return function (object: Object, propertyName: string) {
|
||||
|
||||
const reflectedType = ColumnTypes.typeToString(Reflect.getMetadata("design:type", object, propertyName));
|
||||
const reflectedType = ColumnTypes.typeToString((<any> Reflect).getMetadata("design:type", object, propertyName));
|
||||
|
||||
// if column options are not given then create a new empty options
|
||||
const options: ColumnOptions = {};
|
||||
|
||||
@ -10,7 +10,7 @@ export function TreeParent(options?: RelationOptions): Function {
|
||||
return function (object: Object, propertyName: string) {
|
||||
if (!options) options = {} as RelationOptions;
|
||||
|
||||
const reflectedType = Reflect.getMetadata("design:type", object, propertyName);
|
||||
const reflectedType = (<any> Reflect).getMetadata("design:type", object, propertyName);
|
||||
defaultMetadataStorage().relationMetadatas.add(new RelationMetadata({
|
||||
isTreeParent: true,
|
||||
target: object.constructor,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user