Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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
like image 789
Rakesh Avatar asked Jun 17 '26 00:06

Rakesh


1 Answers

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

example: Book.findByPk(someId)

like image 71
Rakesh Avatar answered Jun 19 '26 18:06

Rakesh