Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feat/#1] MongoDB 데이터 모델링 #19

Merged
merged 10 commits into from
Sep 23, 2021
7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
node_modules/
## 설치된 npm package 제외
node_modules/
package-lock.json

## 환경변수 제외
.env
13 changes: 13 additions & 0 deletions backend/bin/www
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,19 @@
const app = require('../app');
const debug = require('debug')('backend:server');
const http = require('http');
const mongoose = require('mongoose');

require('dotenv').config();

mongoose.connect(process.env.DATABASE_URL,{
useNewUrlParser: true,
useUnifiedTopology: true,
useFindAndModify: false
})
.then(res => console.log("MongoDB Connected"))
.catch(err => console.error(err));

mongoose.Promise = global.Promise; // mongoose 5 이상일 경우 삭제

/**
* Get port from environment and store in Express.
Expand Down
2 changes: 2 additions & 0 deletions backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
"dependencies": {
"cookie-parser": "^1.4.4",
"debug": "^2.6.9",
"dotenv": "^10.0.0",
"express": "^4.16.1",
"mongoose": "^6.0.7",
"morgan": "^1.9.1"
},
"devDependencies": {
Expand Down
Empty file removed backend/src/models/.keep
Empty file.
12 changes: 12 additions & 0 deletions backend/src/models/team.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
const mongoose = require('mongoose');

const Schema = mongoose.Schema;

const teamSchema = new Schema({
title: String,
password: String,
details: String,
userIds: Array,
});

module.exports = mongoose.model('Team', teamSchema);
12 changes: 12 additions & 0 deletions backend/src/models/user.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
const mongoose = require('mongoose');

const Schema = mongoose.Schema;

const userSchema = new Schema({
nickName: String,
email: String,
teamIds: Array,
oauthToken : String,
});

module.exports = mongoose.model('User', userSchema);