Notice
Recent Posts
Recent Comments
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
Tags
- unity
- it
- android
- javascript
- server
- C
- 번역
- MySQL
- 프래그먼트
- php
- NGINX
- 해석
- 컴퓨터과학총론
- 개발자
- caddy
- 한글
- Portfolio
- H2O
- error
- 자바
- mariadb
- 개발
- 안드로이드
- centOS7
- ubuntu
- C lanuage
- 구글
- techEmpower
- java
- kakao
Archives
- Today
- Total
개발모음집
Error: Include unexpected. Element has to be either a Model, an Association or an object 본문
Server/node.js
Error: Include unexpected. Element has to be either a Model, an Association or an object
void 2019. 12. 2. 10:00Error: Include unexpected. Element has to be either a Model, an Association or an object 에러가 발생했다.
에러를 찾아보니 sequelize difine할 때,
defaultScope: {
where: {
active: true
}
}
를 같이 써쭤야한다고 한다.
Sequelize.js: Include unexpected. Element has to be either a Model, an Association or an object
I'm using Sequelize.js in my Node.js application and keep running into a very strange problem. Background: I have two models, Account and AccountCategory as follows. My API endpoint calls the route /
stackoverflow.com
module.exports = (sequelize, DataTypes) => {
const User = sequelize.define('User', {
email: {
type: DataTypes.STRING(40),
allowNull: false,
unique: true,
},
nickname: {
type: DataTypes.STRING(20),
allowNull: false,
},
password: {
type: DataTypes.STRING(100),
allowNull: false,
},
}, {
charset: 'utf8',
collate: 'utf8_general_ci',
defaultScope: {
where: {
email: true // where절을 허용할 컬럼명을 써준다.
}
}
});
User.associate = (db) => {
};
return User;
};
where절 제대로 안쓰면 아래와 같이 컬럼이 없다고 나온다.
SequelizeDatabaseError: Unknown column 'User.active' in 'where clause'