Run callbacks on schema ready

This commit is contained in:
Anatoliy Chakkaev 2011-11-05 16:55:11 +07:00
parent b5985e445d
commit 9f9aa7cd3f
6 changed files with 8 additions and 2 deletions

View File

@ -1,5 +1,6 @@
exports.initialize = function initializeSchema(schema, callback) {
schema.adapter = new Memory();
callback();
};
function Memory() {

View File

@ -6,6 +6,7 @@ var mongoose = require('mongoose');
exports.initialize = function initializeSchema(schema, callback) {
schema.client = mongoose.connect(schema.settings.url);
schema.adapter = new MongooseAdapter(schema.client);
callback();
};
function MongooseAdapter(client) {

View File

@ -15,6 +15,7 @@ exports.initialize = function initializeSchema(schema, callback) {
});
schema.adapter = new MySQL(schema.client);
callback();
};
function MySQL(client) {

View File

@ -6,6 +6,7 @@ var neo4j = require('./neo4j-lib');
exports.initialize = function initializeSchema(schema, callback) {
schema.client = new neo4j.GraphDatabase(schema.settings.url);
schema.adapter = new Neo4j(schema.client);
callback();
};
function Neo4j(client) {

View File

@ -10,7 +10,8 @@ exports.initialize = function initializeSchema(schema, callback) {
schema.settings.options
);
schema.client.auth(schema.settings.password, callback);
schema.client.auth(schema.settings.password);
schema.client.on('connect', callback);
schema.adapter = new BridgeToRedis(schema.client);
};

View File

@ -1,7 +1,8 @@
var Sequelize = require('sequelize');
exports.initialize = function initializeSchema(schema) {
exports.initialize = function initializeSchema(schema, callback) {
schema.adapter = new SequelizeAdapter(schema);
callback();
};
function SequelizeAdapter(schema) {