commit
a8b7f048b5
|
@ -1251,12 +1251,12 @@ DataSource.prototype.idNames = function (modelName) {
|
||||||
*/
|
*/
|
||||||
DataSource.prototype.defineForeignKey = function defineForeignKey(className, key, foreignClassName) {
|
DataSource.prototype.defineForeignKey = function defineForeignKey(className, key, foreignClassName) {
|
||||||
// quit if key already defined
|
// quit if key already defined
|
||||||
if (this.definitions[className].properties[key]) return;
|
if (this.definitions[className].rawProperties[key]) return;
|
||||||
|
|
||||||
if (this.connector.defineForeignKey) {
|
if (this.connector.defineForeignKey) {
|
||||||
var cb = function (err, keyType) {
|
var cb = function (err, keyType) {
|
||||||
if (err) throw err;
|
if (err) throw err;
|
||||||
this.definitions[className].properties[key] = {type: keyType};
|
this.definitions[className].defineProperty(key, {type: keyType});
|
||||||
}.bind(this);
|
}.bind(this);
|
||||||
switch (this.connector.defineForeignKey.length) {
|
switch (this.connector.defineForeignKey.length) {
|
||||||
case 4:
|
case 4:
|
||||||
|
@ -1268,7 +1268,7 @@ DataSource.prototype.defineForeignKey = function defineForeignKey(className, key
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
this.definitions[className].properties[key] = {type: Number};
|
this.definitions[className].defineProperty(key, {type: Number});
|
||||||
}
|
}
|
||||||
|
|
||||||
this.models[className].registerProperty(key);
|
this.models[className].registerProperty(key);
|
||||||
|
|
|
@ -149,6 +149,8 @@ ModelBuilder.prototype.define = function defineClass(className, properties, sett
|
||||||
|
|
||||||
// expose properties on the ModelClass
|
// expose properties on the ModelClass
|
||||||
ModelClass.definition = modelDefinition;
|
ModelClass.definition = modelDefinition;
|
||||||
|
// keep a pointer to settings as models can use it for configuration
|
||||||
|
ModelClass.settings = modelDefinition.settings;
|
||||||
|
|
||||||
var idInjection = settings.idInjection;
|
var idInjection = settings.idInjection;
|
||||||
if(idInjection !== false) {
|
if(idInjection !== false) {
|
||||||
|
|
Loading…
Reference in New Issue