如何使用findById使用Nodejs sequelize在MySQL中编辑和更新特定字段数据?

时间:2019-05-07 06:43:31

标签: javascript mysql node.js angular sequelize.js

这是错误-

TypeError: Customer.findById is not a function
    at exports.findById (E:\Angular 7\anguar_NodeJs_Mysql\NodeJs-mySql\app\controller\customer.controller.js:25:12)at Layer.handle [as handle_request(E:\Angular7\anguar_NodeJs_Mysql\NodeJs
    -MySql\node_modules\express\lib\router\layer.js:95:5)
        at next (E:\Angular 7\anguar_NodeJs_Mysql\NodeJs-MySql\node_modules\express\
    lib\router\route.js:137:13)
        at Route.dispatch (E:\Angular 7\anguar_NodeJs_Mysql\NodeJs-MySql\node_module
    s\express\lib\router\route.js:112:3)
        at Layer.handle [as handle_request] (E:\Angular 7\anguar_NodeJs_Mysql\NodeJs
    -MySql\node_modules\express\lib\router\layer.js:95:5)
        at E:\Angular 7\anguar_NodeJs_Mysql\NodeJs-MySql\node_modules\express\lib\ro
    uter\index.js:281:22
        at param (E:\Angular 7\anguar_NodeJs_Mysql\NodeJs-MySql\node_modules\express
    \lib\router\index.js:354:14)
        at param (E:\Angular 7\anguar_NodeJs_Mysql\NodeJs-MySql\node_modules\express
    \lib\router\index.js:365:14)
        at Function.process_params (E:\Angular 7\anguar_NodeJs_Mysql\NodeJs-MySql\no
    de_modules\express\lib\router\index.js:410:3)

I used this Link example

1 个答案:

答案 0 :(得分:0)

从sequelize版本5开始,findById已删除,而官方的替代方法是findByPk。

引用sequelize migration doc