728x90
SMALL
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
'Node.js' 카테고리의 다른 글
koyeb으로 서버 배포하기 (3) | 2022.10.04 |
---|---|
점호 프로그램 만들기- 과정 (4) | 2022.06.18 |
[출석부 만들기] mongoose 연결하고 mongoDB compass에서 확인하기 (0) | 2022.02.21 |
백, 프론트 서버 동시 실행 시 한쪽을 무시해요 (0) | 2022.02.15 |
[MongoDB] 몽구스 스키마 설계, password 암호화, 저장 (0) | 2022.02.13 |