Comparing version 0.9.1 to 0.9.2
@@ -33,4 +33,4 @@ !function(){ | ||
// generate transactio nclass | ||
this.Transaction = buildTransaction(this); | ||
// build transaction class for this db | ||
Class.define(this, 'Transaction', Class(buildTransaction(this))); | ||
@@ -77,3 +77,3 @@ // emit load not before the next main loop execution | ||
, _initialize: function(definition){ | ||
Object.keys(definition).forEach(function(tablename){ | ||
Object.keys(definition).sort().forEach(function(tablename){ | ||
if (this[tablename]) next(new Error('Failed to load ORM for database «'+this._databaseName+'», the tablename «'+tablename+'» is reserved for the orm.').setName('ORMException')); | ||
@@ -94,4 +94,3 @@ if (dev) log.debug('['+this._databaseName+'] initializing new model «'+tablename+'» ...'); | ||
} | ||
}); | ||
}(); |
@@ -83,6 +83,6 @@ !function(){ | ||
// let the user create a new schema | ||
this.Schema = function() { | ||
Class.define(this, 'Schema', Class(function(schemaName, callback) { | ||
return this.createSchema(schemaName, callback); | ||
}.bind(this))); | ||
}.bind(this) | ||
// db connectivity | ||
@@ -95,10 +95,40 @@ this._initializeDatabases(options); | ||
/* | ||
* | ||
* create a new schema in a database | ||
* | ||
* @returns <Object> a promise or the schame if a callback was passed | ||
* | ||
* @param <String> schemaName, the name for the new schema | ||
* @param <Function> optional callback | ||
*/ | ||
, createSchema: function(name, databaseName) { | ||
, createSchema: function(schemaName, callback) { | ||
if (callback) { | ||
return this; | ||
} | ||
else { | ||
return new Promise(function(resolve, reject) { | ||
this._createSchema(function(err, schema) { | ||
if (err) reject(err); | ||
else resolve(schema); | ||
}.bind(this)); | ||
}.bind(this)); | ||
} | ||
} | ||
/* | ||
* create a new schema in a database | ||
* | ||
* @param <String> schemaName, the name for the new schema | ||
* @param <Function> callback | ||
*/ | ||
, _createSchema: function(schemaName, callback) { | ||
if (this[schemaName]) { | ||
this[schemaName] | ||
} | ||
else callback(new Error('Cannot create schema «'+schemaName+'», you have to specifiy it in the db config first so connections can be created!')); | ||
} | ||
/* | ||
@@ -231,4 +261,5 @@ * accepts extension to the orm | ||
// get definition from database | ||
, function(db, next){ | ||
, function(db, next) { | ||
this._databases[db.databaseName].describe([db.databaseName], function(err, databases){ | ||
@@ -245,8 +276,9 @@ if (dev) log.debug('got db definition for «'+db.databaseName+'»...'); | ||
// initialize orm per databse | ||
, function(db, definition, next){ | ||
, function(db, definition, next) { | ||
var newDefinition = {}; | ||
if (this[db.databaseName]) next(new Error('Failed to load ORM for database «'+db.databaseName+'», the name is reserved for the orm.').setName('ORMException')); | ||
else { | ||
else if (definition.schemaExists()) { | ||
// build the model definitions from the raw definitions | ||
@@ -274,4 +306,6 @@ Object.keys(definition).forEach(function(modelName) { | ||
} | ||
else next(); | ||
}.bind(this) | ||
// check for errors | ||
@@ -400,2 +434,3 @@ , function(err, results){ | ||
this._dbs.push({ | ||
@@ -402,0 +437,0 @@ databaseName : config.schema |
{ | ||
"name" : "ee-orm" | ||
, "description" : "ORM for postgres and mysql. Loads and saves referenced entites, executes complex queries, supports joins, transactions, complex database clusters & connection pooling. No conventions." | ||
, "version" : "0.9.1" | ||
, "description" : "ORM for postgres and mysql. Loads and saves referenced entites, executes complex queries, supports joins, transactions, complex database clusters, connection pooling and much more. No conventions." | ||
, "version" : "0.9.2" | ||
, "homepage" : "https://github.com/eventEmitter/ee-orm" | ||
@@ -27,4 +27,4 @@ , "author" : "Michael van der Weg <michael@eventemitter.com> (http://eventemitter.com/)" | ||
, "ee-db-cluster" : "0.2.x" | ||
, "ee-mysql-connection" : "0.3.x" | ||
, "ee-postgres-connection" : "0.5.x" | ||
, "ee-mysql-connection" : "^0.3.1" | ||
, "ee-postgres-connection" : "^0.5.1" | ||
, "es6-promise" : "2.0.x" | ||
@@ -31,0 +31,0 @@ } |
@@ -21,4 +21,6 @@ | ||
db.event(['*']).find(log); | ||
log(orm); | ||
//db.event(['*']).find(log); | ||
/*var evt = db.event(['*']) | ||
@@ -25,0 +27,0 @@ , ed = evt.getEventData(['*']); |
@@ -34,3 +34,3 @@ | ||
try { | ||
config = require('../config.js').db.filter(function(config) {return config.schema === databaseName}); | ||
config = require('../config-test.js').db.filter(function(config) {return config.schema === databaseName}); | ||
} catch(e) { | ||
@@ -37,0 +37,0 @@ config = []; |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
286686
5467
Updatedee-mysql-connection@^0.3.1