Comparing version 0.0.2-alpha.40 to 0.0.2-alpha.41
@@ -90,2 +90,3 @@ import { PropertyMetadata } from "./PropertyMetadata"; | ||
readonly name: string; | ||
readonly target: Function | string; | ||
/** | ||
@@ -119,4 +120,4 @@ * Indicates if this column is in embedded, not directly in the table. | ||
readonly embeddedProperty: string; | ||
hasEntityValue(entity: any): any; | ||
hasEntityValue(entity: any): boolean; | ||
getEntityValue(entity: any): any; | ||
} |
@@ -11,3 +11,3 @@ "use strict"; | ||
constructor(args) { | ||
super(args.target, args.propertyName); | ||
super(undefined, args.propertyName); | ||
/** | ||
@@ -82,2 +82,5 @@ * Type's length in the database. | ||
} | ||
get target() { | ||
return this.entityMetadata.target; | ||
} | ||
/** | ||
@@ -134,7 +137,10 @@ * Indicates if this column is in embedded, not directly in the table. | ||
if (this.isInEmbedded) { | ||
return entity.hasOwnProperty(this.embeddedProperty) && | ||
entity[this.embeddedProperty].hasOwnProperty(this.propertyName); | ||
return entity[this.embeddedProperty] !== undefined && | ||
entity[this.embeddedProperty] !== null && | ||
entity[this.embeddedProperty][this.propertyName] !== undefined && | ||
entity[this.embeddedProperty][this.propertyName] !== null; | ||
} | ||
else { | ||
return entity.hasOwnProperty(this.propertyName); | ||
return entity[this.propertyName] !== undefined && | ||
entity[this.propertyName] !== null; | ||
} | ||
@@ -141,0 +147,0 @@ } |
{ | ||
"name": "typeorm", | ||
"private": false, | ||
"version": "0.0.2-alpha.40", | ||
"version": "0.0.2-alpha.41", | ||
"description": "Data-mapper ORM for Typescript", | ||
@@ -6,0 +6,0 @@ "license": "Apache-2.0", |
@@ -13,3 +13,4 @@ "use strict"; | ||
transform(newEntity, object, metadata) { | ||
return this.groupAndTransform(newEntity, object, metadata); | ||
this.groupAndTransform(newEntity, object, metadata); | ||
return newEntity; | ||
} | ||
@@ -39,9 +40,11 @@ // ------------------------------------------------------------------------- | ||
let subEntity = relationMetadata.create(); | ||
// todo: support custom initial fields here | ||
if (entity[relation.propertyName] instanceof Array) { | ||
// todo: support custom initial fields here | ||
subEntity = entity[relation.propertyName].find((subEntity) => { | ||
const existRelation = entity[relation.propertyName].find((subEntity) => { | ||
return subEntity[relation.referencedColumnName] === subObject[relation.referencedColumnName]; | ||
}); | ||
this.groupAndTransform(subEntity, existRelation, relationMetadata); | ||
} | ||
return this.groupAndTransform(subEntity, subObject, relationMetadata); | ||
this.groupAndTransform(subEntity, subObject, relationMetadata); | ||
return subEntity; | ||
}); | ||
@@ -55,4 +58,7 @@ } | ||
if (object[relation.propertyName]) { | ||
const subEntity = entity[relation.propertyName] || relationMetadata.create(); | ||
entity[relation.propertyName] = this.groupAndTransform(subEntity, object[relation.propertyName], relationMetadata); | ||
const subEntity = relationMetadata.create(); | ||
if (entity[relation.propertyName]) | ||
this.groupAndTransform(subEntity, entity[relation.propertyName], relationMetadata); | ||
this.groupAndTransform(subEntity, object[relation.propertyName], relationMetadata); | ||
entity[relation.propertyName] = subEntity; | ||
} | ||
@@ -64,3 +70,2 @@ else { | ||
}); | ||
return entity; | ||
} | ||
@@ -67,0 +72,0 @@ } |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
921856
13256