removed reflect metadata

This commit is contained in:
Umed Khudoiberdiev 2016-05-13 18:02:18 +05:00
parent ae7b362560
commit 43d90f4a0b
14 changed files with 15 additions and 21 deletions

View File

@ -1,4 +1,3 @@
import "reflect-metadata";
import {NamingStrategyMetadata} from "../metadata/NamingStrategyMetadata";
import {defaultMetadataStorage} from "../typeorm";

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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));

View File

@ -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;

View File

@ -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;

View File

@ -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,

View File

@ -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,

View File

@ -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,

View File

@ -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,

View File

@ -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({

View File

@ -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 = {};

View File

@ -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,