출처: https://bumcrush.tistory.com/182 [맑음때때로 여름]

git-scm.com/download/win

 

Git - Downloading Package

Downloading Git Now What? Now that you have downloaded Git, it's time to start using it.

git-scm.com

 

git init (깃 생성)

Microsoft Windows [Version 10.0.19041.804]
(c) 2020 Microsoft Corporation. All rights reserved.

C:\Users\bit\Documents\boiler-plate>git init
Initialized empty Git repository in C:/Users/bit/Documents/boiler-plate/.git/

C:\Users\bit\Documents\boiler-plate>git status
On branch master

No commits yet

Untracked files:
  (use "git add <file>..." to include in what will be committed)
        index.js
        models/
        node_modules/
        package-lock.json
        package.json

nothing added to commit but untracked files present (use "git add" to track)

C:\Users\bit\Documents\boiler-plate>

 

git add를 하면 소ㅑㄹ라소ㅑㄹ라~~ 라이브러리까지 다 올라감.. (staging area에)

 

C:\Users\bit\Documents\boiler-plate>git add .
warning: LF will be replaced by CRLF in node_modules/.bin/mime.
The file will have its original line endings in your working directory
warning: LF will be replaced by CRLF in node_modules/.bin/mime.ps1.
The file will have its original line endings in your working directory
warning: LF will be replaced by CRLF in node_modules/.bin/semver.
The file will have its original line endings in your working directory
C:\Users\bit\Documents\boiler-plate>git status
On branch master

No commits yet

Changes to be committed:
  (use "git rm --cached <file>..." to unstage)
        new file:   index.js
        new file:   models/User.js
        new file:   node_modules/.bin/mime
        new file:   node_modules/.bin/mime.cmd
        new file:   node_modules/.bin/mime.ps1
        new file:   node_modules/.bin/semver
        new file:   node_modules/.bin/semver.cmd

 

 

staging area에 올라간 ㅎㅎ.. node_modules (라이브러리)는 지워준다..

C:\Users\bit\Documents\boiler-plate>git rm --cached node_modules -r
rm 'node_modules/.bin/mime'
rm 'node_modules/.bin/mime.cmd'
rm 'node_modules/.bin/mime.ps1'
rm 'node_modules/.bin/semver'
rm 'node_modules/.bin/semver.cmd'
rm 'node_modules/.bin/semver.ps1'
rm 'node_modules/@types/bson/LICENSE

 

그리고 .gitignore 만들어줌..

 

 

commit -m "메모"

(깃허브에서 메모하는거랑 같은 것..)


C:\Users\bit\Documents\boiler-plate>git status
On branch master

No commits yet

Changes to be committed:
  (use "git rm --cached <file>..." to unstage)
        new file:   index.js
        new file:   models/User.js
        new file:   package-lock.json
        new file:   package.json

Untracked files:
  (use "git add <file>..." to include in what will be committed)
        .gitignore


C:\Users\bit\Documents\boiler-plate>git commit -m "처음 저장소 올림"
[master (root-commit) 1540315] 처음 저장소 올림
 4 files changed, 668 insertions(+)
 create mode 100644 index.js
 create mode 100644 models/User.js
 create mode 100644 package-lock.json
 create mode 100644 package.json

C:\Users\bit\Documents\boiler-plate>git status
On branch master
Untracked files:
  (use "git add <file>..." to include in what will be committed)
        .gitignore


C:\Users\bit\Documents\boiler-plate>git commit -m "깃이그노어 추가"
[master 684ec62] 깃이그노어 추가
 1 file changed, 1 insertion(+)
 create mode 100644 .gitignore

C:\Users\bit\Documents\boiler-plate>git status
On branch master
nothing to commit, working tree clean

C:\Users\bit\Documents\boiler-plate>

'DB > ETC' 카테고리의 다른 글

[mongodb] model & Schema 생성  (0) 2021.02.24
[mongodb] 유저생성 및 nodejs 몽고 DB연결  (0) 2021.02.24
[mongodb] 몽고DB 클러스터 생성하기  (0) 2021.02.24
const mongoose = require('mongoose')

const userSchema = mongoose.Schema({

    name :{
        type : String,
        maxlength : 50
    },
    email : {
        type : String,
        trim : true,
        unique : 1
    },
    passworld : {
        type : String,
        minlegth : 5
    },
    lastname :{
        type : String,
        maxlength : 50
    },
    role : {
        type : Number,
        default : 0
    },
    image : String,
    token : {
        type : String
    },
    tokenExp : {
        type : Number
    }

})

const User = mongoose.model('User', userSchema)
module.exports = {User}

'DB > ETC' 카테고리의 다른 글

[GIT] git 설치  (0) 2021.02.24
[mongodb] 유저생성 및 nodejs 몽고 DB연결  (0) 2021.02.24
[mongodb] 몽고DB 클러스터 생성하기  (0) 2021.02.24

connect 누르고 username과 password 입력후 생성

 

체크 ~ 체크~

 

 

저 부분 복사해놓는다.

혹시몰라서 일단 가렸는데 별로 그럴 필요없었네;

 

 

몽구스 설치하기

 

VSCODE 터미널 혹은 cmd에서 npm install mongoose --save

 

 

package.json에 보면 mongoose가 생긴 것을 볼 수 있다.

 

 

몽고 DB 연결하기

 

const express = require('express')
const app = express()
const port = 3000


const mongoose = require('mongoose')
mongoose.connect('mongodb+srv://HYOSEON:비번@hyseonbolierplate.9vvek.mongodb.net/myFirstDatabase?retryWrites=true&w=majority',{
    useNewUrlParser: true, useUnifiedTopology:true, useCreateIndex:true, useFindAndModify :false
}).then(() => console.log('mongoDB Connected..'))
 .catch(err => console.log(err))

app.get('/', (req, res) => {  res.send('Hello World!')})

app.listen(port, () => {  console.log(`Example app listening at http://localhost:${port}`)})

 

비번이라고 된 부분엔 비번 쳐준다

복사할땐 <password>라고 되있지만 <>도 다 지워야함.

 

 

 

 

 

 

-- 인강이 너무 미리 설치된게 많아서 알아보고 다 다시해야했던 부분도 기록

npm 설치해야 터미널에서 npm run start 이런거 다 쓸 수 있음.

그리고 비밀번호에 @가 있을때도 에러가 난다고 한다.. 난 그냥 영문+숫자 조합으로 했다.

cloud.mongodb.com/v2/6035f632c682c16cee78ea88#security/database/users

비번 수정 등등은 여기서 가능..

 

 

cloud.mongodb.com/v2/6035f632c682c16cee78ea88#security/network/accessList

첫부분에 IP 추가해주던가 네트워크엑세스(링크) 들어가서 IP추가해줘야됌..

인강에서는 미리 다 추가가 되있어서 에러가 나지 않았던 것이었다.

 

연결 완료~

 

'DB > ETC' 카테고리의 다른 글

[GIT] git 설치  (0) 2021.02.24
[mongodb] model & Schema 생성  (0) 2021.02.24
[mongodb] 몽고DB 클러스터 생성하기  (0) 2021.02.24

인강을 듣는데 몽고 DB에서 클러스터 생성하는 페이지가 바뀌어서 헤매다가 찾아서 기록으로 남긴다.

 

인강에서는 맨처음에 들어가면 클러스터 생성이 뜨는데 바뀌어서 

일단 create an organizations를 눌러준다(초록버튼)

뭐라뭐라 뜨는데 그냥 이름 아무거나 입력해줌..

 

그럼 이제는 new Project를 생성하라고 한다.

역시 생성해줌..

 

프로젝트까지 생성하고 나면 클러스터를 생성할 수 있다.

 

 

당연히 프리선택 ^^^^

 

세개 중에 맘에 드는거 선택..

무료중에서는 한국이랑 제일 가까운 싱가폴 선택 추천

 

선택하고 클러스터네임은 자기맘대로 아무거나..

 

 

클러스터 생성되는데 몇분 걸린다. 끝!

'DB > ETC' 카테고리의 다른 글

[GIT] git 설치  (0) 2021.02.24
[mongodb] model & Schema 생성  (0) 2021.02.24
[mongodb] 유저생성 및 nodejs 몽고 DB연결  (0) 2021.02.24

+ Recent posts