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
throughargument.[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
asargument 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.fieldsinstead.[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 optionsas arguments, the second and fourth argumentcalleeandreplacementshave been removed and should be set viaoptions.instance/options.modelandoptions.replacementsinstead.[REMOVED]
instance.isDirtyhas been removed, useinstance.changed()instead[REMOVED]
instance.valueshas been removed, useinstance.get()instead[REMOVED]
instance.primaryKeyValueshas been removed.[REMOVED]
instance.identifiershas been removed, useinstance.where()instead[REMOVED]
instance.isDeletedhas been removed, simply check the timestamp withget('deletedAt')instead[REMOVED]
instance.increment/decrementnow 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 usewhere: ["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。
引用来自“要吃九个橙子”的评论
NodeJS ORM 那帮人是怎么想到的啊。。引用来自“liluwei123”的评论
你做事务,就知道还是关系数据库方便点! 比如 财务系统!引用来自“要吃九个橙子”的评论
NodeJS ORM 那帮人是怎么想到的啊。。引用来自“Fover”的评论
mongodb不是已经很方便了么。。。。