Skip to content

Commit

Permalink
Bandaid order-of-operations with associations
Browse files Browse the repository at this point in the history
  • Loading branch information
mde committed Oct 30, 2012
1 parent 3b046f6 commit ab8745f
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions lib/index.js
Expand Up @@ -801,9 +801,14 @@ model.ModelDefinitionBase = function (name) {
assn[name] = true;
reg[self.name].associations[assnKey] = assn;
if (assnKey == 'belongsTo') {
def = model[name];
idDatatype = def.autoIncrementId ? 'int' : 'string';
self.property(utils.string.decapitalize(name) + 'Id', idDatatype);
// FIXME: Hack, let other models get defined first
// Should probably listen for an event that signals
// base models are set up
setTimeout(function () {
def = model[name];
idDatatype = def.autoIncrementId ? 'int' : 'string';
self.property(utils.string.decapitalize(name) + 'Id', idDatatype);
}, 0);
}
};
});
Expand Down

0 comments on commit ab8745f

Please sign in to comment.