일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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
- node
- Android
- event-driven
- ssh key
- Express
- Mongo
- MaridDB
- react-native
- elemMatch
- MEAN stack
- instance
- Modulization
- Mongoose
- Linux
- Setup
- window
- centos
- proguard
- memory structure
- rest-assured
- OOP
- Java
- API테스트
- PBKDF2
- iIntelliJ
- 다중 서버 명령
- 64k method
- multidex
- pbkdf2-password
- Git
Archives
- Today
- Total
천줄코딩도 한 걸음부터
Mongoose로 Node.js와 연결 시 DeprecationWarning 본문
// mongodb setup
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');
});
다음과 같은 Warning이 발생함
(node:1876) DeprecationWarning: `open()` is deprecated in mongoose >= 4.11.0, use `openUri()` instead, or set the `useMongoClient` option if using `connect()` or `createConnection()`. See http://mongoosejs.com/docs/connections.html#use-mongo-client
// mongodb setup
var mongoose = require('mongoose');
var promise = mongoose.connect('mongodb://localhost/mydb', {
useMongoClient: true
});
var db = mongoose.connection;
db.on('error', console.error.bind(console, 'connection error:'));
db.once('open', function() {
// we're connected!
console.log('connected successfully');
});
useMongoClient 옵션을 사용해 Warning 해결
'Others' 카테고리의 다른 글
MongoDB find elemMatch projection option (0) | 2017.07.08 |
---|---|
MongoDB 기존 document에 데이터 추가하기 $push (0) | 2017.07.06 |
Node.js 비밀번호 보안(Password Security) (0) | 2017.07.06 |
MongoDB를 통해 Node.js에서 간단한 REST API 구현 (0) | 2017.07.06 |
Express에서 Mongoose로 DB 연결 (0) | 2017.07.06 |