Rakesh
Rakesh

Reputation: 841

TypeError: Modelname.findById is not a function with sequelize nodejs

I want to find value from table with respect to Id passed in api. When using findByID to find one record I am getting below errro.

TypeError: Modelname.findById is not a function

Upvotes: 3

Views: 378

Answers (1)

Rakesh
Rakesh

Reputation: 841

findById is from old version of Sequelize module. Now they are using findByPk to find single record from table .

example: Book.findByPk(someId)

Upvotes: 2

Related Questions