sequelize
Advanced tools
Comparing version 1.2.1 to 1.3.0
195
changelog.md
@@ -1,48 +0,79 @@ | ||
# v0.1.0 # | ||
- first stable version | ||
- implemented all basic functions | ||
- associations are working | ||
# v1.3.0 # | ||
- [REFACTORING] Model#all is now a function and not a getter. | ||
- [REFACTORING] Renamed ModelDefinition to ModelFactory | ||
- [REFACTORING] Private method scoping; Attributes are still public | ||
- [REFACTORING] Use the new util module for node 0.6.2 | ||
- [FEATURE] QueryChainer can now run serially | ||
- [FEATURE] Association definition is chainable: Person.hasOne(House).hasMany(Address) | ||
- [FEATURE] Validations (Thanks to [hiddentao](https://github.com/hiddentao)) | ||
- [FEATURE] jQuery-like event listeners: .success(callback) and .error(callback) | ||
- [FEATURE] aliasing for select queries: Model.find({ where: 'id = 1', attributes: ['id', ['name', 'username']] }) ==> will return the user's name as username | ||
- [FEATURE] cross-database support. currently supported: mysql, sqlite | ||
- [FEATURE] migrations | ||
- [TEST] removed all expresso tests and converted them to jasmine | ||
# v0.2.0 # | ||
- added methods for setting associations | ||
- added method for chaining an arbitraty amount of queries | ||
# v1.2.1 # | ||
- [REFACTORING] renamed the global options for sync, query and define on sequelize; before: options.queryOptions; now: options.query | ||
- [FEATURE] allow definition of charset via global define option in sequelize or via charset option in sequelize.define | ||
- [FEATURE] allow definition of mysql engine via global define option in sequelize or via engine option in sequelize.define; default is InnoDB now | ||
- [FEATURE] find and findAll will now search in a list of values via: Model.findAll({where: { id: [1,2,3] }}); will return all models with id 1, 2 and 3 | ||
- [TEST] force latin1 charset for travis | ||
# v0.2.1 # | ||
- fixed date bug | ||
# v1.2.0 # | ||
- [FEATURE] min/max function for models, which return the min/max value in a column | ||
- [FEATURE] getModel for modelManager for getting a model without storing it in a variable; use it via sequelize.modelManager.getModel('User') | ||
- [TEST] test suite refactoring for jasmine | ||
# v0.2.2 # | ||
- released project as npm package | ||
# v1.1.4 # | ||
- [BUG] tables with identical prefix (e.g. wp_) can now be used in many-to-many associations | ||
# v0.2.3 # | ||
- added latest mysql connection library | ||
- fixed id handling on save | ||
- fixed text handling (varchar > 255; text) | ||
- using the inflection library for naming tables more convenient | ||
- Sequelize.TEXT is now using MySQL datatype TEXT instead of varchar(4000) | ||
# v1.1.3 # | ||
- [BUG] scoped options in model => a model can now have the attribute options | ||
- [FEATURE] added drop method for sequelize, that drops all currently registered tables | ||
# v0.2.4 # | ||
- fixed bug when using cross associated tables (many to many associations) | ||
# v1.1.2 # | ||
- [BUG] prevent malfunction after being idle | ||
# v0.2.5 # | ||
- added BOOLEAN type | ||
- added FLOAT type | ||
- fixed DATE type issue | ||
- fixed npm package | ||
# v1.1.1 # | ||
- [BUG] fixed memory leaks | ||
- [FEATURE] added query queueing (adjustable via maxConcurrentQueries in config; default: 50) | ||
# v0.2.6 # | ||
- refactored Sequelize to fit CommonJS module conventions | ||
# v1.1.0 # | ||
- [BUG] defaultValue 0 is now working | ||
- [REMOVED] mysql-pool usage (will give it a new try later) | ||
- [CHORE] updated node-mysql to 0.9.4 | ||
# v0.3.0 # | ||
- added possibility to define class and instance methods for models | ||
- added import method for loading model definition from a file | ||
# v1.0.2 # | ||
- [BUG] Fixed where clause generation for models with explicit primary keys (allanca) | ||
- [BUG] Set insertId for non-default auto increment fields (allanca) | ||
# v0.4.0 # | ||
- added error handling when defining invalid database credentials | ||
- Sequelize#sync, Sequelize#drop, model#sync, model#drop returns errors via callback | ||
- code is now located under lib/sequelize to use it with nDistro | ||
- added possibility to use non default mysql database (host/port) | ||
- added error handling when defining invalid database port/host | ||
- schema definitions can now contain default values and null allowance | ||
- database credentials can now also contain an empty / no password | ||
# v1.0.1 # | ||
- [FEATURE] Added Model.count(callback), which returns the number of elements saved in the database | ||
- [BUG] Fixed self associations | ||
# v1.0.0 # | ||
- complete rewrite | ||
- added new emitter syntax | ||
- sql injection protection | ||
- select now supports hash usage of where | ||
- select now supports array usage of where | ||
- added a lot of options to find/findAll | ||
- Wrapped queries correctly using `foo` | ||
- using expresso 0.7.2 | ||
- moved config for test database into seperated config file | ||
- Added method for adding and deleting single associations | ||
# v0.4.3 # | ||
- renamed loadAssociatedData to fetchAssociations | ||
- renamed Model#associatedData to fetchedAssociations | ||
- added fetchAssociations to finder methods | ||
- store data found by finder method in the associatedData hash + grep them from there if reload is not forced | ||
- added option to sequelize constructor for disabling the pluralization of tablenames: disableTableNameModification | ||
- allow array as value for chainQueries => Sequelize.chainQueries([save: [a,b,c]], callback) | ||
- remove the usage of an array => Sequelize.chainQueries({save: a}, {destroy: b}, callback) | ||
# v0.4.2 # | ||
- fixed bugs from 0.4.1 | ||
- added the model instance method loadAssociatedData which adds the hash Model#associatedData to an instance which contains all associated data | ||
# v0.4.1 # | ||
@@ -59,64 +90,48 @@ - THIS UPDATE CHANGES TABLE STRUCTURES MASSIVELY! | ||
# v0.4.2 # | ||
- fixed bugs from 0.4.1 | ||
- added the model instance method loadAssociatedData which adds the hash Model#associatedData to an instance which contains all associated data | ||
# v0.4.0 # | ||
- added error handling when defining invalid database credentials | ||
- Sequelize#sync, Sequelize#drop, model#sync, model#drop returns errors via callback | ||
- code is now located under lib/sequelize to use it with nDistro | ||
- added possibility to use non default mysql database (host/port) | ||
- added error handling when defining invalid database port/host | ||
- schema definitions can now contain default values and null allowance | ||
- database credentials can now also contain an empty / no password | ||
# v0.4.3 # | ||
- renamed loadAssociatedData to fetchAssociations | ||
- renamed Model#associatedData to fetchedAssociations | ||
- added fetchAssociations to finder methods | ||
- store data found by finder method in the associatedData hash + grep them from there if reload is not forced | ||
- added option to sequelize constructor for disabling the pluralization of tablenames: disableTableNameModification | ||
- allow array as value for chainQueries => Sequelize.chainQueries([save: [a,b,c]], callback) | ||
- remove the usage of an array => Sequelize.chainQueries({save: a}, {destroy: b}, callback) | ||
# v0.3.0 # | ||
- added possibility to define class and instance methods for models | ||
- added import method for loading model definition from a file | ||
# v1.0.0 # | ||
- complete rewrite | ||
- added new emitter syntax | ||
- sql injection protection | ||
- select now supports hash usage of where | ||
- select now supports array usage of where | ||
- added a lot of options to find/findAll | ||
- Wrapped queries correctly using `foo` | ||
- using expresso 0.7.2 | ||
- moved config for test database into seperated config file | ||
- Added method for adding and deleting single associations | ||
# v0.2.6 # | ||
- refactored Sequelize to fit CommonJS module conventions | ||
# v1.0.1 # | ||
- Added Model.count(callback), which returns the number of elements saved in the database | ||
- Fixed self associations | ||
# v0.2.5 # | ||
- added BOOLEAN type | ||
- added FLOAT type | ||
- fixed DATE type issue | ||
- fixed npm package | ||
# v1.0.2 # | ||
- Fixed where clause generation for models with explicit primary keys (allanca) | ||
- Set insertId for non-default auto increment fields (allanca) | ||
# v0.2.4 # | ||
- fixed bug when using cross associated tables (many to many associations) | ||
# 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 | ||
# v0.2.3 # | ||
- added latest mysql connection library | ||
- fixed id handling on save | ||
- fixed text handling (varchar > 255; text) | ||
- using the inflection library for naming tables more convenient | ||
- Sequelize.TEXT is now using MySQL datatype TEXT instead of varchar(4000) | ||
# v1.1.1 # | ||
- fixed memory leaks | ||
- added query queueing (adjustable via maxConcurrentQueries in config; default: 50) | ||
# v0.2.2 # | ||
- released project as npm package | ||
# v1.1.2 # | ||
- prevent malfunction after being idle | ||
# v0.2.1 # | ||
- fixed date bug | ||
# v1.1.3 # | ||
- [BUG] scoped options in model => a model can now have the attribute options | ||
- [FEATURE] added drop method for sequelize, that drops all currently registered tables | ||
# v0.2.0 # | ||
- added methods for setting associations | ||
- added method for chaining an arbitraty amount of queries | ||
# v1.1.4 # | ||
- [BUG] tables with identical prefix (e.g. wp_) can now be used in many-to-many associations | ||
# v0.1.0 # | ||
- first stable version | ||
- implemented all basic functions | ||
- associations are working | ||
# v1.2.0 # | ||
- [FEATURE] min/max function for models, which return the min/max value in a column | ||
- [FEATURE] getModel for modelManager for getting a model without storing it in a variable; use it via sequelize.modelManager.getModel('User') | ||
- [TEST] test suite refactoring for jasmine | ||
# v1.2.1 # | ||
- [REFACTORING] renamed the global options for sync, query and define on sequelize; before: options.queryOptions; now: options.query | ||
- [FEATURE] allow definition of charset via global define option in sequelize or via charset option in sequelize.define | ||
- [FEATURE] allow definition of mysql engine via global define option in sequelize or via engine option in sequelize.define; default is InnoDB now | ||
- [FEATURE] find and findAll will now search in a list of values via: Model.findAll({where: { id: [1,2,3] }}); will return all models with id 1, 2 and 3 | ||
- [TEST] force latin1 charset for travis |
@@ -1,1 +0,1 @@ | ||
module.exports = require("./lib/sequelize/sequelize") | ||
module.exports = require("./lib/sequelize") |
{ | ||
"name": "sequelize", | ||
"description": "MySQL ORM for Node.JS", | ||
"version": "1.2.1", | ||
"version": "1.3.0", | ||
"author": "Sascha Depold <sascha@depold.com>", | ||
@@ -10,10 +10,13 @@ "contributors": [ | ||
"dependencies": { | ||
"mysql": "=0.9.4", | ||
"underscore": "=1.1.5", | ||
"underscore.string": "=1.1.3", | ||
"lingo": "=0.0.4" | ||
"mysql": "0.9.x", | ||
"underscore": "1.2.x", | ||
"underscore.string": "2.0.x", | ||
"lingo": "0.0.x", | ||
"validator": "0.3.x", | ||
"moment": "1.1.x", | ||
"commander": "0.5.x" | ||
}, | ||
"devDependencies": { | ||
"jasmine-node": "=1.0.12", | ||
"expresso": "=0.9.2" | ||
"jasmine-node": "1.0.x", | ||
"sqlite3": ">=2.0.0" | ||
}, | ||
@@ -23,4 +26,9 @@ "keywords": ["mysql", "orm", "nodejs", "object relational mapper"], | ||
"scripts": {}, | ||
"bin": {}, | ||
"engines": { "node": ">= 0.1.93" } | ||
"bin": { | ||
"sequelize": "bin/sequelize" | ||
}, | ||
"engines": { | ||
"node": ">=0.4.6" | ||
}, | ||
"license": "MIT" | ||
} |
@@ -5,2 +5,5 @@ # Sequelize # | ||
## v1.2.1 ## | ||
I highly recommend to [read this article about the changes in sequelize 1.2.1](http://blog.depold.com/post/12319530694/changes-in-sequelize-1-2-1), which changes some defaults and some interfaces. | ||
## Features ## | ||
@@ -20,3 +23,5 @@ | ||
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. 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). | ||
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). | ||
An article about changes in 1.2.1. can be found [here](http://blog.depold.com/post/12319530694/changes-in-sequelize-1-2-1) | ||
@@ -29,8 +34,6 @@ ## Collaboration ## | ||
In order to run the tests, just do ```npm install```, which will install expresso and jasmine. I am switching from | ||
expresso to jasmine, so please add according tests to your pull requests. This is how you start the tests: | ||
In order to run the tests, just do ```npm install```, which will install jasmine. Please add tests to your pull requests. This is how you start the tests: | ||
node_modules/.bin/expresso -s test/**/* | ||
node_modules/.bin/jasmine-node spec/ | ||
Current build status on travis-ci: [![Build Status](https://secure.travis-ci.org/sdepold/sequelize.png)](http://travis-ci.org/sdepold/sequelize) |
@@ -9,12 +9,28 @@ var Factories = module.exports = function(helpers) { | ||
var self = this | ||
var self = this | ||
, models = [] | ||
this.helpers.async(function(done) { | ||
self.sequelize.modelManager.getModel(modelName).create(options).on('success', function(model){ | ||
done() | ||
--count ? self.Model(modelName, options, callback, count) : (callback && callback(model)) | ||
}).on('failure', function(err) { | ||
console.log(err) | ||
done() | ||
}) | ||
var Model = self.sequelize.modelManager.getModel(modelName) | ||
var create = function(cb) { | ||
Model.create(options).on('success', function(model) { | ||
models.push(model) | ||
cb && cb() | ||
}).on('failure', function(err) { | ||
console.log(err) | ||
done() | ||
}) | ||
} | ||
var cb = function() { | ||
if(--count) { | ||
create(cb) | ||
} else { | ||
done() | ||
callback && callback(models) | ||
} | ||
} | ||
create(cb) | ||
}) | ||
@@ -21,0 +37,0 @@ } |
@@ -0,1 +1,3 @@ | ||
Sequelize = require("../../index") | ||
var Helpers = module.exports = function(sequelize) { | ||
@@ -11,4 +13,4 @@ this.sequelize = sequelize | ||
.sync({force: true}) | ||
.on('success', done) | ||
.on('failure', function(err) { console.log(err) }) | ||
.success(done) | ||
.failure(function(err) { console.log(err) }) | ||
}) | ||
@@ -27,2 +29,14 @@ } | ||
Helpers.prototype.dropAllTables = function() { | ||
var self = this | ||
this.async(function(done) { | ||
self.sequelize | ||
.getQueryInterface() | ||
.dropAllTables() | ||
.success(done) | ||
.error(function(err) { console.log(err) }) | ||
}) | ||
} | ||
Helpers.prototype.async = function(fct) { | ||
@@ -29,0 +43,0 @@ var done = false |
@@ -1,13 +0,66 @@ | ||
var config = require("./config/config") | ||
, Sequelize = require("../index") | ||
var config = require("./config/config") | ||
, Sequelize = require("../index") | ||
, QueryInterface = require("../lib/query-interface") | ||
describe('Sequelize', function() { | ||
it('should pass the global options correctly', function() { | ||
var sequelize = new Sequelize(config.database, config.username, config.password, { | ||
logging: false, | ||
define: { underscored:true } | ||
var sequelize = null | ||
, Helpers = null | ||
var setup = function(options) { | ||
options = options || {logging: false} | ||
sequelize = new Sequelize(config.database, config.username, config.password, options) | ||
Helpers = new (require("./config/helpers"))(sequelize) | ||
return options | ||
} | ||
beforeEach(function() { setup() }) | ||
afterEach(function() { sequelize = null }) | ||
describe('constructor', function() { | ||
it('should pass the global options correctly', function() { | ||
setup({ logging: false, define: { underscored:true } }) | ||
var Model = sequelize.define('model', {name: Sequelize.STRING}) | ||
expect(Model.options.underscored).toBeTruthy() | ||
}) | ||
var Model = sequelize.define('model', {name: Sequelize.STRING}) | ||
expect(Model.options.underscored).toBeTruthy() | ||
it('should correctly set the host and the port', function() { | ||
var options = setup({ host: '127.0.0.1', port: 1234 }) | ||
expect(sequelize.config.host).toEqual(options.host) | ||
expect(sequelize.config.port).toEqual(options.port) | ||
}) | ||
}) | ||
describe('define', function() { | ||
it("adds a new model to the model manager", function() { | ||
expect(sequelize.modelManager.all.length).toEqual(0) | ||
sequelize.define('foo', { title: Sequelize.STRING }) | ||
expect(sequelize.modelManager.all.length).toEqual(1) | ||
}) | ||
}) | ||
describe('sync', function() { | ||
it("synchronizes all models", function() { | ||
var Project = sequelize.define('project' + config.rand(), { title: Sequelize.STRING }) | ||
var Task = sequelize.define('task' + config.rand(), { title: Sequelize.STRING }) | ||
Helpers.async(function(done) { | ||
sequelize.sync().success(function() { | ||
Project.create({title: 'bla'}).success(function() { | ||
Task.create({title: 'bla'}).success(done) | ||
}) | ||
}) | ||
}) | ||
}) | ||
}) | ||
describe('import', function() { | ||
it("imports a model definition from a file", function() { | ||
var Project = sequelize.import(__dirname + "/assets/project") | ||
expect(Project).toBeDefined() | ||
}) | ||
}) | ||
}) |
Sorry, the diff of this file is not supported yet
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
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
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
434095
5162
37
7
75
23
1
+ Addedcommander@0.5.x
+ Addedmoment@1.1.x
+ Addedvalidator@0.3.x
+ Addedarray-buffer-byte-length@1.0.1(transitive)
+ Addedarraybuffer.prototype.slice@1.0.3(transitive)
+ Addedavailable-typed-arrays@1.0.7(transitive)
+ Addedcall-bind@1.0.7(transitive)
+ Addedcommander@0.5.2(transitive)
+ Addeddata-view-buffer@1.0.1(transitive)
+ Addeddata-view-byte-length@1.0.1(transitive)
+ Addeddata-view-byte-offset@1.0.0(transitive)
+ Addeddefine-data-property@1.1.4(transitive)
+ Addeddefine-properties@1.2.1(transitive)
+ Addedes-abstract@1.23.3(transitive)
+ Addedes-define-property@1.0.0(transitive)
+ Addedes-errors@1.3.0(transitive)
+ Addedes-object-atoms@1.0.0(transitive)
+ Addedes-set-tostringtag@2.0.3(transitive)
+ Addedes-to-primitive@1.2.1(transitive)
+ Addedfor-each@0.3.3(transitive)
+ Addedfunction-bind@1.1.2(transitive)
+ Addedfunction.prototype.name@1.1.6(transitive)
+ Addedfunctions-have-names@1.2.3(transitive)
+ Addedget-intrinsic@1.2.4(transitive)
+ Addedget-symbol-description@1.0.2(transitive)
+ Addedglobalthis@1.0.4(transitive)
+ Addedgopd@1.0.1(transitive)
+ Addedhas-bigints@1.0.2(transitive)
+ Addedhas-property-descriptors@1.0.2(transitive)
+ Addedhas-proto@1.0.3(transitive)
+ Addedhas-symbols@1.0.3(transitive)
+ Addedhas-tostringtag@1.0.2(transitive)
+ Addedhashish@0.0.4(transitive)
+ Addedhasown@2.0.2(transitive)
+ Addedinternal-slot@1.0.7(transitive)
+ Addedis-array-buffer@3.0.4(transitive)
+ Addedis-bigint@1.0.4(transitive)
+ Addedis-boolean-object@1.1.2(transitive)
+ Addedis-callable@1.2.7(transitive)
+ Addedis-data-view@1.0.1(transitive)
+ Addedis-date-object@1.0.5(transitive)
+ Addedis-negative-zero@2.0.3(transitive)
+ Addedis-number-object@1.0.7(transitive)
+ Addedis-regex@1.1.4(transitive)
+ Addedis-shared-array-buffer@1.0.3(transitive)
+ Addedis-string@1.0.7(transitive)
+ Addedis-symbol@1.0.4(transitive)
+ Addedis-typed-array@1.1.13(transitive)
+ Addedis-weakref@1.0.2(transitive)
+ Addedisarray@2.0.5(transitive)
+ Addedlingo@0.0.5(transitive)
+ Addedmoment@1.1.1(transitive)
+ Addedmysql@0.9.6(transitive)
+ Addedobject-inspect@1.13.2(transitive)
+ Addedobject-keys@1.1.1(transitive)
+ Addedobject.assign@4.1.5(transitive)
+ Addedpossible-typed-array-names@1.0.0(transitive)
+ Addedregexp.prototype.flags@1.5.3(transitive)
+ Addedsafe-array-concat@1.1.2(transitive)
+ Addedsafe-regex-test@1.0.3(transitive)
+ Addedset-function-length@1.2.2(transitive)
+ Addedset-function-name@2.0.2(transitive)
+ Addedside-channel@1.0.6(transitive)
+ Addedstring.prototype.trim@1.2.9(transitive)
+ Addedstring.prototype.trimend@1.0.8(transitive)
+ Addedstring.prototype.trimstart@1.0.8(transitive)
+ Addedtraverse@0.6.10(transitive)
+ Addedtyped-array-buffer@1.0.2(transitive)
+ Addedtyped-array-byte-length@1.0.1(transitive)
+ Addedtyped-array-byte-offset@1.0.2(transitive)
+ Addedtyped-array-length@1.0.6(transitive)
+ Addedtypedarray.prototype.slice@1.0.3(transitive)
+ Addedunbox-primitive@1.0.2(transitive)
+ Addedunderscore@1.2.4(transitive)
+ Addedunderscore.string@2.0.0(transitive)
+ Addedvalidator@0.3.9(transitive)
+ Addedwhich-boxed-primitive@1.0.2(transitive)
+ Addedwhich-typed-array@1.1.15(transitive)
Updatedlingo@0.0.x
Updatedmysql@0.9.x
Updatedunderscore@1.2.x
Updatedunderscore.string@2.0.x