일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 | 29 | 30 |
Tags
- MEAN stack
- Android
- iIntelliJ
- instance
- Java
- multidex
- Mongo
- ssh key
- node
- OOP
- MaridDB
- Setup
- Express
- centos
- Mongoose
- Modulization
- Git
- PBKDF2
- proguard
- Linux
- event-driven
- 다중 서버 명령
- react-native
- elemMatch
- 64k method
- API테스트
- rest-assured
- memory structure
- pbkdf2-password
- window
Archives
- Today
- Total
천줄코딩도 한 걸음부터
Express에서 Mongoose로 DB 연결 본문
1. npm을 통해 mongoose 모듈 설치
npm install mongoose
2. 자바스크립트 작성
connection-test.js
var mongoose = require('mongoose');
mongoose.connect('mongodb://localhost/mydb');
var db = mongoose.connection;
db.on('error', console.error.bind(console, 'connection error:'));
db.once('open', function() {
// we're connected!
console.log('connected successfully');
});
3. 실행
node connection-test.js
'Others' 카테고리의 다른 글
Node.js 비밀번호 보안(Password Security) (0) | 2017.07.06 |
---|---|
MongoDB를 통해 Node.js에서 간단한 REST API 구현 (0) | 2017.07.06 |
Window 32bit MongoDB 설치하기 (0) | 2017.07.06 |
AWS EC2 인스턴스 생성 및 Putty로 접속하기 (8) | 2017.06.23 |
Node.js 모듈 (0) | 2017.06.23 |