when using cradle if we don't wait for the schema to be connected, the models fails to load correctly.

This commit is contained in:
Muneeb Samuels 2012-11-10 20:14:13 +02:00
parent 75c96bdaa9
commit fa50e0e5e8
1 changed files with 19 additions and 15 deletions

View File

@ -28,6 +28,9 @@ if (existsSync(confFile)) {
var schema = new Schema(config && config.driver || 'memory', config); var schema = new Schema(config && config.driver || 'memory', config);
schema.log = log; schema.log = log;
// when using cradle if we dont wait for the schema to be connected, the models fails to load correctly.
schema.on('connected', function() {
railway.orm._schemas.push(schema); railway.orm._schemas.push(schema);
context = prepareContext(schema); context = prepareContext(schema);
@ -50,6 +53,7 @@ if (schemaFile) {
railway.orm._schemas.forEach(function (schema) { railway.orm._schemas.forEach(function (schema) {
schema.freeze(); schema.freeze();
}); });
});
// check validations and display warning // check validations and display warning