红联Linux门户
Linux帮助

Sequelize.js 3.0.0发布,Node.js的ORM框架

发布时间:2015-05-19 09:13:19来源:红联作者:empast
Sequelize.js 提供对 MySQL,MariaDB,SQLite 和 PostgreSQL 数据库的简单访问,通过映射数据库条目到对象,或者对象到数据库条目。简而言之,就是 ORM(Object-Relational-Mapper)。Sequelize.js 完全是使用 JavaScript 编写,适用于 Node.js 的环境。

Sequelize.js 3.0.0 发布,此版本清理了废弃的代码,更好的维护和开发。

主要更新内容如下:

[ADDED] findById / findByPrimary takes a single value as argument representing the primary key to find.

[CHANGED] belongsToMany relations MUST now be given a through argument.

[CHANGED] findOne / findAll / findAndCount / findOrCreate now only takes a single options argument instead of a options and queryOptions argument. So set transaction, raw, etc on the first options argument.

[CHANGED] The accessor for belongsToMany relationships is now either the as argument or the target model name pluralized.

[REMOVED] N:M relationships can no longer be represented by 2 x hasMany

[REMOVED] Model.create / Model.bulkCreate / Instance.save no longer takes an array of fields as its second argument, use options.fields instead.

[REMOVED] Query Chainer has been removed

[REMOVED] Migrations have been removed, use umzug instead

[REMOVED] Model.findAllJoin has been removed

[REMOVED] sequelize.query now only takes sql and options as arguments, the second and fourth argument callee and replacements have been removed and should be set via options.instance / options.model and options.replacements instead.

[REMOVED] instance.isDirty has been removed, use instance.changed() instead

[REMOVED] instance.values has been removed, use instance.get() instead

[REMOVED] instance.primaryKeyValues has been removed.

[REMOVED] instance.identifiers has been removed, use instance.where() instead

[REMOVED] instance.isDeleted has been removed, simply check the timestamp with get('deletedAt') instead

[REMOVED] instance.increment/decrement now longer takes a number as it's second argument.

[REMOVED/SECURITY] findOne no longer takes a string / integer / binary argument to represent a primaryKey. Use findById instead

[REMOVED/SECURITY] where: "raw query" is no longer legal, you must now explicitely use where: ["raw query", [replacements]]

[BUG] Fix showIndexQuery so appropriate indexes are returned when a schema is used

[BUG] Fix addIndexQuery error when the model has a schema

[BUG] Fix app crash in sqlite while running in special unique constraint errors #3730

[BUG] Fix bulkCreate: do not insert NULL for undefined values #3729

[BUG] Fix trying to roll back a comitted transaction if an error occured while comitting resulting in an unhandled rejection #3726

[BUG] Fix regression in beforeUpdate hook where instance.changed() would always be false #3727

[BUG] Fix trying to roll back a comitted transaction if an error occured while comitting

向后兼容改进

Most of the changes in 3.0.0 are BC breaking, read the changelog for 3.0.0 carefully.

The error that is thrown when a column is declared to be an enum but without any values used to "Values for ENUM haven't been defined" and is now "Values for ENUM have not been defined".

此版本现已提供下载:https://github.com/sequelize/sequelize/archive/v3.0.0.zip

来自:开源中国社区
文章评论

共有 0 条评论