Code clean up
This commit is contained in:
parent
7f170a0542
commit
2f575482c0
|
@ -233,10 +233,6 @@ ModelDefinition.prototype.resolveType = function(type) {
|
||||||
} else {
|
} else {
|
||||||
return this.modelBuilder.define(this.modelBuilder.getSchemaName(null),
|
return this.modelBuilder.define(this.modelBuilder.getSchemaName(null),
|
||||||
type, {anonymous: true, idInjection: false});
|
type, {anonymous: true, idInjection: false});
|
||||||
/*
|
|
||||||
console.error(type);
|
|
||||||
throw new Error('Missing type property');
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
} else if('function' === typeof type ) {
|
} else if('function' === typeof type ) {
|
||||||
return type;
|
return type;
|
||||||
|
@ -259,22 +255,19 @@ ModelDefinition.prototype.build = function (forceRebuild) {
|
||||||
}
|
}
|
||||||
this.properties = {};
|
this.properties = {};
|
||||||
for (var p in this.rawProperties) {
|
for (var p in this.rawProperties) {
|
||||||
var type = this.resolveType(this.rawProperties[p]);
|
var prop = this.rawProperties[p];
|
||||||
|
var type = this.resolveType(prop);
|
||||||
if (typeof type === 'string') {
|
if (typeof type === 'string') {
|
||||||
if (Array.isArray(this.associations)) {
|
|
||||||
this.associations.push({
|
this.associations.push({
|
||||||
source: this.name,
|
source: this.name,
|
||||||
target: type,
|
target: type,
|
||||||
relation: Array.isArray(this.rawProperties[p]) ? 'hasMany' : 'belongsTo',
|
relation: Array.isArray(prop) ? 'hasMany' : 'belongsTo',
|
||||||
as: p
|
as: p
|
||||||
});
|
});
|
||||||
// delete this.rawProperties[p];
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
var typeDef = {
|
var typeDef = {
|
||||||
type: type
|
type: type
|
||||||
};
|
};
|
||||||
var prop = this.rawProperties[p];
|
|
||||||
if (typeof prop === 'object' && prop !== null) {
|
if (typeof prop === 'object' && prop !== null) {
|
||||||
for (var a in prop) {
|
for (var a in prop) {
|
||||||
// Skip the type property but don't delete it Model.extend() shares same instances of the properties from the base class
|
// Skip the type property but don't delete it Model.extend() shares same instances of the properties from the base class
|
||||||
|
|
Loading…
Reference in New Issue