Presentation is loading. Please wait.

Presentation is loading. Please wait.

웹 어플리케이션 보안 2016년 2학기 3. Mongo db.

Similar presentations


Presentation on theme: "웹 어플리케이션 보안 2016년 2학기 3. Mongo db."— Presentation transcript:

1 웹 어플리케이션 보안 2016년 2학기 3. Mongo db

2 3. Mongo DB Chap 8. Using MongoDB

3 MongoDB란? 높은 성능, 높은 가용성을 가진 사용하기 쉬운 데이터베 이스 JSON 형식의 문서형 데이터베이스
DB (MongoDB) Server (node.js) Front-end (AngularJS)

4 사용 방법 2가지 1. Local에 설치하여 사용 2. MongoDB의 호스트 서비스 이용 https://modulus.io/

5 MongoDB 사용 절차 1. MongoDB 설치 2. 데이터를 저장할 폴더 생성
mongod [ --dbpath ] 4. MongoDB 서버에 연결하여 사용 mongo

6 MongoDB 설치하기

7 MongoDB 설치하기 시스템 환경변수 path에 MongoDB 설치폴더 등록
Path=C:\Program Files\MongoDB\Server\3.2\bin

8 MongoDB 서버 실행 데이터를 저장할 폴더 생성 C:\data\db 서버 실행 (데이터를 저장할
폴더를 지정하여 실행해야 함) mongod --dbpath C:\data\db 서버 실행중… Waiting for connections on port 27017

9 클라이언트에서 MongoDB에 연결 서버 실행중인 명령창은 그대로 두고 새로운 명령창 열기 mongo 명령어로 서버에 연결
데이터베이스 목록 보기 show databases 현재 사용중인 데이터베이스 보기 db 데이터베이스 선택하기 use db_name test 데이터베이스는 mongoDB 설치시 디폴트 설치되는 데이터베이스임

10 데이터 폴더 보기 데이터 폴더에 파일들이 생성됨

11 CRUD 명령어 (생성, 읽기, 변경, 삭제) Create Read Update Delete save 명령 find 명령
// save one user db.users.save({ name: 'Chris' }); // save multiple users db.users.save([{ name: 'Chris'}, { name: 'Holly' }]); Create Read Update Delete save 명령 // show all users db.users.find(); // find a specific user db.users.find({ name: 'Holly' }); find 명령 db.users.update({ name: 'Holly' }, { name: 'Holly Lloyd' }); update 명령 // remove all db.users.remove({}); // remove one db.users.remove({ name: 'Holly' }); remove 명령 SQL: 테이블(table)과 레코드(record) NoSQL: 컬렉션(collection)과 문서(document)

12 CRUD 명령어 MongoDB에서는 DB 스키 마를 명시적으로 생성하지 않아도 됨
데이터를 저장하기 시작하 면 스키마가 자동 생성됨

13 CRUD 명령어 https://docs.mongodb.com/manual/crud/ 참조 Create Operations
db.collection.insert() db.collection.insertOne() New in version 3.2 db.collection.insertMany() New in version 3.2 Read Operations db.collection.find() Update Operations db.collection.update() db.collection.updateOne() New in version 3.2 db.collection.updateMany() New in version 3.2 db.collection.replaceOne() New in version 3.2 Delete Operations db.collection.remove() db.collection.deleteOne() New in version 3.2 db.collection.deleteMany() New in version 3.2

14 GUI Tool: Robomongo 활용 MongoDB의 GUI 관리 툴 Robomongo 설치

15 Robomongo 활용

16 Node.js 프로그램에서 MongoDB 사용하기
MongooseJS 설치 MongoDB를 사용하기 위한 Node 패키지 Mongoose를 이용하여 MongoDB에 연결하기 npm install mongoose --save // grab the packages we need var mongoose = require('mongoose'); mongoose.connect('mongodb://localhost/db_name'); 다음 장에 상세한 예제 계속됨


Download ppt "웹 어플리케이션 보안 2016년 2학기 3. Mongo db."

Similar presentations


Ads by Google