sequelize
Advanced tools
Comparing version 1.0.2 to 1.1.0
@@ -90,2 +90,7 @@ # v0.1.0 # | ||
- Fixed where clause generation for models with explicit primary keys (allanca) | ||
- Set insertId for non-default auto increment fields (allanca) | ||
- Set insertId for non-default auto increment fields (allanca) | ||
# v1.1.0 # | ||
- defaultValue 0 is now working | ||
- REVERTED mysql-pool usage (will give it a new try later) | ||
- updated node-mysql to 0.9.4 |
var Utils = require("./utils") | ||
var Query = module.exports = function(databaseConfig, callee, options) { | ||
this.config = databaseConfig | ||
var Query = module.exports = function(client, callee, options) { | ||
var self = this | ||
this.client = client | ||
this.callee = callee | ||
this.options = options || {} | ||
this.client.on('error', function(err) { self.onFailure(err) }) | ||
} | ||
@@ -11,9 +15,2 @@ Utils.addEventEmitter(Query) | ||
var self = this | ||
var client = new (require("mysql").Client)({ | ||
user: this.config.username, | ||
password: this.config.password, | ||
host: this.config.host, | ||
port: this.config.port, | ||
database: this.config.database | ||
}) | ||
this.sql = query | ||
@@ -24,8 +21,5 @@ | ||
client.connect() | ||
client.query(this.sql, function(err, results, fields) { | ||
this.client.query(this.sql, function(err, results, fields) { | ||
err ? self.onFailure(err) : self.onSuccess(self.sql, results, fields) | ||
}) | ||
client.on('error', function(err) { self.onFailure(err) }) | ||
client.end() | ||
}).setMaxListeners(100) | ||
@@ -32,0 +26,0 @@ return this |
@@ -22,2 +22,3 @@ var Utils = require("./utils") | ||
} | ||
this.connectorManager = new (require('./connector-manager'))(this.config) | ||
} | ||
@@ -30,2 +31,4 @@ Sequelize.Utils = Utils | ||
if(this.options.defineOptions) options = Sequelize.Utils.merge(options, this.options.defineOptions) | ||
var model = this.modelManager.addModel(new ModelDefinition(modelName, attributes, options)) | ||
@@ -43,7 +46,23 @@ | ||
options = options || {} | ||
if(this.options.queryOptions) options = Sequelize.Utils.merge(options, this.options.queryOptions) | ||
if(!this.connectorManager.isConnected) this.connectorManager.connect() | ||
options.logging = this.options.hasOwnProperty('logging') ? this.options.logging : true | ||
return new Query(this.config, callee, options).run(sql) | ||
var self = this | ||
, query = new Query(this.connectorManager.client, callee, options).run(sql) | ||
query | ||
.on('success', function(){ self.connectorManager.check() }) | ||
.on('failure', function(){ self.connectorManager.check() }) | ||
return query | ||
}, | ||
sync: function(options) { | ||
options = options || {} | ||
if(this.options.syncOptions) options = Sequelize.Utils.merge(options, this.options.syncOptions) | ||
var self = this | ||
@@ -66,2 +85,2 @@ var eventEmitter = new Utils.CustomEventEmitter(function() { | ||
Sequelize.Utils._.map(DataTypes, function(sql, accessor) { Sequelize[accessor] = sql}) | ||
Sequelize.Utils._.map(instanceMethods, function(fct, name) { Sequelize.prototype[name] = fct}) | ||
Sequelize.Utils._.map(instanceMethods, function(fct, name) { Sequelize.prototype[name] = fct}) |
@@ -91,3 +91,3 @@ var client = new (require("mysql").Client)() | ||
if(dataType.autoIncrement) template +=" auto_increment" | ||
if(dataType.defaultValue) { | ||
if(dataType.defaultValue != undefined) { | ||
template += " DEFAULT <%= defaultValue %>" | ||
@@ -141,2 +141,8 @@ replacements.defaultValue = Utils.escape(dataType.defaultValue) | ||
return Utils.Lingo.en.isPlural(s) ? s : Utils.Lingo.en.pluralize(s) | ||
}, | ||
merge: function(a, b){ | ||
for(var key in b) { | ||
a[key] = b[key] | ||
} | ||
return a | ||
} | ||
@@ -158,2 +164,2 @@ } | ||
Utils.QueryChainer = require("./query-chainer") | ||
Utils.Lingo = require("lingo") | ||
Utils.Lingo = require("lingo") |
{ | ||
"name": "sequelize", | ||
"description": "MySQL ORM for Node.JS", | ||
"version": "1.0.2", | ||
"version": "1.1.0", | ||
"author": "Sascha Depold <sascha@depold.com>", | ||
@@ -10,3 +10,3 @@ "contributors": [ | ||
"dependencies": { | ||
"mysql": ">=0.9.1", | ||
"mysql": ">=0.9.4", | ||
"underscore": ">=1.1.5", | ||
@@ -13,0 +13,0 @@ "underscore.string": ">=1.1.3", |
@@ -19,4 +19,8 @@ # Sequelize # | ||
If you want to know about latest development and releases, follow me on [Twitter](http://twitter.com/sdepold). | ||
Also make sure to take a look at the examples in the repository. The website will contain them soon, as well. | ||
Also make sure to take a look at the examples in the repository. The website will contain them soon, as well. For a (more or less) complete overview of changes in 1.0.0. take a look at [this blogpost](http://blog.depold.com/post/5936116582/changes-in-sequelize-1-0-0). | ||
## Collaboration ## | ||
I'm glad to get pull request if any functionality is missing or something is buggy. But _please_ ... run the tests before you send me the pull request. | ||
## Tests ## | ||
@@ -23,0 +27,0 @@ |
@@ -14,3 +14,5 @@ var assert = require("assert") | ||
var User2 = s.define('User', { name: Sequelize.STRING, bio: Sequelize.TEXT }) | ||
User2.sync().on('failure', function(){exit(function(){})}) | ||
User2.sync().on('failure', function(err){ | ||
exit(function(){} | ||
)}) | ||
}, | ||
@@ -17,0 +19,0 @@ 'drop should work': function(exit) { |
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
378837
105
2848
29
Updatedmysql@>=0.9.4