sjfkai
sjfkai

Reputation: 98

Why sequelize can not call increment without an instance?

According to official doc Incrementing certain values of an instance.

We can increment values of an instance.

But why can not we call increment by Sequelize directly?

Upvotes: 1

Views: 360

Answers (1)

Ivan Drinchev
Ivan Drinchev

Reputation: 19581

Because it's an Instance's method and not a model's method.

You can use something like :

someModel.update( { clicks : sequelize.literal( "clicks + 1" ) } ) )

if you want to increment all instances in a model.

Upvotes: 2

Related Questions