Skip to content

Commit

Permalink
feat : 시퀄라이저 추가하여 모델 만들기
Browse files Browse the repository at this point in the history
mic050r committed Feb 5, 2024
1 parent 66ad866 commit bc74a41
Showing 9 changed files with 213 additions and 166 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -5,4 +5,7 @@ nodejs-api
# kakao login 파일을 ignore
login.js

.env
.env

config/database.js
models/index.js
13 changes: 0 additions & 13 deletions db/conn.js

This file was deleted.

94 changes: 0 additions & 94 deletions db/createTable.js

This file was deleted.

58 changes: 0 additions & 58 deletions db/init.sql

This file was deleted.

40 changes: 40 additions & 0 deletions models/Concept.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// models/Concept.js
const { DataTypes, Model } = require("sequelize");

class Concept extends Model {
static init(sequelize) {
return super.init(
{
concept_id: {
type: DataTypes.INTEGER,
primaryKey: true,
autoIncrement: true,
},
user_id: {
type: DataTypes.INTEGER,
allowNull: false,
},
importance: {
type: DataTypes.INTEGER,
},
description: {
type: DataTypes.STRING(300),
},
},
{
sequelize,
modelName: "Concept",
tableName: "concept",
charset: "utf8",
collate: "utf8_general_ci",
timestamps: false, // timestamps 옵션을 false로 설정
}
);
}

static associate(models) {
this.belongsTo(models.User, { foreignKey: "user_id" });
}
}

module.exports = Concept;
43 changes: 43 additions & 0 deletions models/Inquiry.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// models/Inquiry.js
const { DataTypes, Model } = require("sequelize");

class Inquiry extends Model {
static init(sequelize) {
return super.init(
{
inquiry_id: {
type: DataTypes.INTEGER,
primaryKey: true,
autoIncrement: true,
},
user_id: {
type: DataTypes.INTEGER,
allowNull: false,
},
title: {
type: DataTypes.STRING(255),
},
message: {
type: DataTypes.TEXT,
},
status: {
type: DataTypes.STRING(50),
},
},
{
sequelize,
modelName: "Inquiry",
tableName: "inquiry",
charset: "utf8",
collate: "utf8_general_ci",
timestamps: false, // timestamps 옵션을 false로 설정
}
);
}

static associate(models) {
this.belongsTo(models.User, { foreignKey: "user_id" });
}
}

module.exports = Inquiry;
43 changes: 43 additions & 0 deletions models/Quiz.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// models/Quiz.js
const { DataTypes, Model } = require("sequelize");

class Quiz extends Model {
static init(sequelize) {
return super.init(
{
quiz_id: {
type: DataTypes.INTEGER,
primaryKey: true,
autoIncrement: true,
},
user_id: {
type: DataTypes.INTEGER,
allowNull: false,
},
importance: {
type: DataTypes.INTEGER,
},
question: {
type: DataTypes.STRING(300),
},
description: {
type: DataTypes.STRING(300),
},
},
{
sequelize,
modelName: "Quiz",
tableName: "quiz",
charset: "utf8",
collate: "utf8_general_ci",
timestamps: false, // timestamps 옵션을 false로 설정
}
);
}

static associate(models) {
this.belongsTo(models.User, { foreignKey: "user_id" });
}
}

module.exports = Quiz;
43 changes: 43 additions & 0 deletions models/User.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// models/User.js
const { DataTypes, Model } = require("sequelize");

class User extends Model {
static init(sequelize) {
return super.init(
{
id: {
type: DataTypes.INTEGER,
primaryKey: true,
autoIncrement: true,
},
kakao_id: {
type: DataTypes.BIGINT,
allowNull: false,
},
nickname: {
type: DataTypes.STRING(50),
},
image: {
type: DataTypes.STRING(300),
},
},
{
sequelize,
modelName: "Useur",
tableName: "user",
charset: "utf8", // 추가: 문자 인코딩 설정
collate: "utf8_general_ci", // 추가: collate 설정
timestamps: false, // timestamps 옵션을 false로 설정
}
);
}

static associate(models) {
this.hasMany(models.Concept, { foreignKey: "user_id" });
this.hasMany(models.Quiz, { foreignKey: "user_id" });
this.hasMany(models.Wrong, { foreignKey: "user_id" });
this.hasMany(models.Inquiry, { foreignKey: "user_id" });
}
}

module.exports = User;
40 changes: 40 additions & 0 deletions models/Wrong.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// models/Wrong.js
const { DataTypes, Model } = require("sequelize");

class Wrong extends Model {
static init(sequelize) {
return super.init(
{
wrong_id: {
type: DataTypes.INTEGER,
primaryKey: true,
autoIncrement: true,
},
user_id: {
type: DataTypes.INTEGER,
allowNull: false,
},
importance: {
type: DataTypes.INTEGER,
},
description: {
type: DataTypes.STRING(300),
},
},
{
sequelize,
modelName: "Wrong",
tableName: "wrong",
charset: "utf8",
collate: "utf8_general_ci",
timestamps: false, // timestamps 옵션을 false로 설정
}
);
}

static associate(models) {
this.belongsTo(models.User, { foreignKey: "user_id" });
}
}

module.exports = Wrong;

0 comments on commit bc74a41

Please sign in to comment.