// 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 해결
'Web > Node.js' 카테고리의 다른 글
Node.js String.replace 문자열 변경 (0) | 2017.07.11 |
---|---|
Node.js multiparty 이용해 File upload - ajax (2) | 2017.07.09 |
Node.js 비밀번호 보안(Password Security) (0) | 2017.07.06 |
MongoDB를 통해 Node.js에서 간단한 REST API 구현 (0) | 2017.07.06 |
Node.js 모듈 (0) | 2017.06.23 |