From ab8745f8377080f516181de50405c2985ec7834d Mon Sep 17 00:00:00 2001 From: mde Date: Mon, 29 Oct 2012 18:25:00 -0700 Subject: [PATCH] Bandaid order-of-operations with associations --- lib/index.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/index.js b/lib/index.js index c90833b1..1fc680a3 100644 --- a/lib/index.js +++ b/lib/index.js @@ -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); } }; });