User.findOne is not a function
728x90
SMALL

https://stackoverflow.com/questions/44248753/ssequelizejs-mysql-and-passportjs-user-findone-not-a-function

 

Ssequelizejs, MySQL and passportjs user.findOne not a function

I'm currently migrating from mongodb to MySQL in my Node js application. I use sequelize as ORM, but I'm having some trouble migrating some passportjs code. I have the following modal. user.js: ...

stackoverflow.com

https://stackoverflow.com/questions/41924961/user-findone-is-not-a-function

 

User.findOne() is not a function

passport.use('local-signup', new LocalStrategy({ // by default, local strategy uses username and password, we will override with email usernameField : 'email', passwordField : 'password...

stackoverflow.com

첫번째 링크로 해결하였음.

const User = require('../models/user'); //에서
const User = require('../models').User; //로 수정
This is like this because of the way the models are dynamically exported. You can have a look at your files, models/index.js. There you will find how each model is exported in a single object. So you basically always require the models/index.js and there specify which key you want to access, in this case "User”

모델이 동적으로 내보내지는 방식 때문에 이렇게 됩니다. models/index.js 에서 각 모델이 단일 객체로 내보내지는 방법을 확인할 수 있습니다. 따라서 기본적으로 항상 models/index.js가 필요되며 여기에 액세스할 키를 지정해야 합니다.

728x90
LIST