forked from sequelize/sequelize
-
Notifications
You must be signed in to change notification settings - Fork 0
Upgrade from 2.0 to 3.0
Sushant edited this page Jun 25, 2016
·
2 revisions
Sequelize 3.0 was a major change in library. Most of changes introduced are breaking changes. Here is list of major changes that you should care about
-
findById
/findByPrimary
added. They accept single argument which can be used to find a record based on a primary key value. They also acceptoptions
as second argument. -
findOne
/findAll
/findAndCount
/findOrCreate
they all now accept singleoptions
argument. -
create
/bulkCreate
/save
no longer takes an array of fields as its second argument, useoptions.fields
instead. - (REMOVED)
findAllJoin
-
findOne
will acceptoptions
argument and will no longer takestring
/integer
/binary
as argument -
increment
/decrement
no longer take number in second argument
-
belongsToMany
now requiredthrough
option. This mean use of junction table withbelongsToMany
is now required. For other cases you can usehasMany
for 1:N relations -
belongsToMany
accessor methods will be based onas
parameter or target model name. -
N:M
relation can't be represented by2x hasMany
, you should usebelongsToMany
now.
- Removed
- Query Chainer
- Migrations, use sequelize/umzug and sequelize/cli
-
instance.isDirty
, useinstance.changed()
-
instance.values
, useinstance.get()
instance.primaryKeyValues
-
instance.identifiers
, useinstance.where()
-
instance.isDeleted
, now simply check timestampget('deletedAt')
-
where: "raw query"
, usewhere: ["raw query", [replacements]]
- Changes
-
sequelize.query
now only takessql and options
as arguments, the second and fourth argumentcallee
andreplacements
has been removed and should be set viaoptions.instance
/options.model
andoptions.replacements
instead. - (DEPRECATED)
referecesKey
property in Model attributes, usereferences
object:{type: Sequelize.INTEGER, references: { model: SomeModel, key: 'some_key' }}
-
Getting Started
- Installation
- Basic Setup
- With Express.JS
- Sequelize CLI
- Relationships
- 1 : 1
- 1 : n
- n : m
- Polymorph
- Hooks
- Pooling
- Debugging
- Migrations
How To
Resources
Upgrade Guides
- 3.0 to 4.0
- 2.0 to 3.0
- 1.7 to 2.0
Help