Permalink
Browse files

Bandaid order-of-operations with associations

  • Loading branch information...
1 parent 3b046f6 commit ab8745f8377080f516181de50405c2985ec7834d mde committed Oct 30, 2012
Showing with 8 additions and 3 deletions.
  1. +8 −3 lib/index.js
View
@@ -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);
}
};
});

0 comments on commit ab8745f

Please sign in to comment.