5.2.9
๋ฒ์ ์ผ๋ก ์
๋ฐ์ดํธํ ํ ์น ์ฑ์ ์์ํ ๋ ํญ์ ์ฝ์์ ์ด ๋ฉ์์ง๊ฐ ํ์๋ฉ๋๋ค.
DeprecationWarning: collection.ensureIndex is deprecated. Use createIndexes instead.
๊ทธ๋ฆฌ๊ณ ์ ๋ ๋ ๋ค ์ฌ์ฉํ์ง ์์ต๋๋ค.
#6880์ ์ค๋ณต
@bricss ๋ฌธ์ ๋ฅผ ์ ๊ณ ํด ์ฃผ์
์ ๊ฐ์ฌํฉ๋๋ค. ๋ชฝ๊ตฌ์ค๋ ๋ด๋ถ์ ์ผ๋ก ensureIndex()
๋ฅผ ํธ์ถํฉ๋๋ค. ์ง๊ธ์ ๊ฒฝ๊ณ ๋ฅผ ์์ ํ๊ฒ ๋ฌด์ํ๊ฑฐ๋ ๋
ธ๋ ํ๋๊ทธ --no-deprecation
๋ก ๊ฒฝ๊ณ ๋ฅผ ๋ฌด์ํ๊ฑฐ๋ ์์กดํ๊ณ ์๋ 5.2.9์ ํน์ ์์ ์ฌํญ์ด ์๋ ๊ฒฝ์ฐ 5.2.8๋ก ๋ค์ด๊ทธ๋ ์ด๋ํ ์ ์์ต๋๋ค. ์
๋ฐ์ดํธ๋ฅผ ์ํด #6880 ํ๋ก์ฐ ๐
,unique: true,index: true๋ ๋ด ์คํค๋ง ์ค ํ๋์ ํ๋์ ์์ผ๋ฉฐ ์ด ๊ฒฝ๊ณ ๋ฅผ ํธ๋ฆฌ๊ฑฐํฉ๋๋ค. ์ด ๊ฒฝ๊ณ ๋ฅผ ๋ฐ์ง ์๊ณ ๊ณ ์ ํ ๊ฐ์ ๋ณด์ฅํ๋ ๋ฐฉ๋ฒ์ ๋ํด ์ง๋ฌธํ์ญ์์ค.
@nonniv ๋ฅผ 5.2.10์ผ๋ก ์
๊ทธ๋ ์ด๋ํ๊ณ mongoose.set('useCreateIndex', true);
์ค์
๋ฒ์ 5.2.10์ผ๋ก ์ ๊ทธ๋ ์ด๋ํ ํ. ์๋ ์ต์ ์ค ๊ฒฝ๊ณ ๋ฅผ ์ค์งํด์ผ ํ๋ ์ต์ ์ด ์์ต๋๊น?
js
mongoose.connect(config.dbUri, {
useCreateIndex: true,
useNewUrlParser: true
})
๋๋
js
mongoose.set('useCreateIndex', true)
mongoose.connect(config.dbUri, { useNewUrlParser: true })
์ฌ๊ธฐ์์ ์๋ํ์ง ์์์ต๋๋ค. (์ ๊ฐ ์๋ชปํ๊ฑฐ๋ผ๋ฉด ์ฃ์กํฉ๋๋ค)
@samuelcecilio ์ด๋ค ํน์ ์ฌ์ฉ ์ค๋จ ๊ฒฝ๊ณ ๊ฐ ํ์๋๋์? #6922๋ฅผ ์ฌ๋ ๋๊ธ์ ๋ช ๊ฐ์ง ์ ์ฉํ ๋ฉ๋ชจ๊ฐ ์์ต๋๋ค. ๋๋ ์ฌ๊ธฐ์ ํน์ ๊ฒฝ๊ณ ๋ฅผ ๊ณต์ ํด ์ฃผ์ธ์. ์ ๊ฐ ๋์ธ ์ ์๋์ง ํ์ธํ๊ฒ ์ต๋๋ค.
(node:9125) DeprecationWarning: collection.ensureIndex is deprecated. Use createIndexes instead.
@samuelcecilio mongoose.set('useCreateIndex', true)
๋ ๋ค์ ์์์ ๋ณผ ์ ์๋ฏ์ด ๊ฒฝ๊ณ ๋ฅผ ์ค์งํด์ผ ํฉ๋๋ค.
#!/usr/bin/env node
'use strict';
const mongoose = require('mongoose');
mongoose.connect('mongodb://localhost:27017/test', { useNewUrlParser: true });
mongoose.set('useCreateIndex', true);
const conn = mongoose.connection;
const Schema = mongoose.Schema;
const schema = new Schema({
name: {
type: String,
unique: true
}
});
const Test = mongoose.model('test', schema);
const test = new Test({ name: 'one' });
async function run() {
console.log(`mongoose version: ${mongoose.version}`);
await conn.dropDatabase();
await test.save();
return conn.close();
}
run();
issues: ./6922.js
mongoose version: 5.2.10
issues:
๋น์ ์ ํ๋ก์ ํธ๊ฐ 5.2.10์ ์ฌ์ฉํ๊ณ ์๋ค๊ณ ํ์ ํฉ๋๊น? ๋ค๋ฅธ ๋ฒ์ ์ ๋ชฝ๊ตฌ์ค ๋ฑ์ ์ฌ์ฉํ๋ ํ๋ก์ ํธ์ ๋ค๋ฅธ ํจํค์ง๊ฐ ์์ต๋๊น?
์๋ ํ์ธ์, ๋ต๋ณ ๊ฐ์ฌํฉ๋๋ค. ์, ๋ฒ์ ์ ์ธ ๋ฒ ํ์ธํ์ต๋๋ค.
$ npm list --depth=0
...
[email protected]
...
๋ด ์ฝ๋
์ฑ.js
````js
...
const ๊ตฌ์ฑ = ํ์('./config')
const ๋ชฝ๊ตฌ์ค = ์๊ตฌ('๋ชฝ๊ตฌ์ค')
const ํํ = ์๊ตฌ('ํํ')
const ์ฑ = ์ต์คํ๋ ์ค()
mongoose.connect(config.dbUri, { useNewUrlParser: true })
mongoose.set('useCreateIndex', ์ฐธ)
....
module.exports = ์ฑ
````
๋น/www
````js
const ์ฑ = ํ์('../์ฑ')
const ๊ตฌ์ฑ = ํ์('../config')
const ๋๋ฒ๊ทธ = ์๊ตฌ('๋๋ฒ๊ทธ')('์ ๊ฒฉ ๊ณต๊ฒฉ')
const http = ์๊ตฌ('http')
const ํฌํธ = normalizePort(process.env.PORT || config.port)
const ๋ชฝ๊ตฌ์ค = ์๊ตฌ('๋ชฝ๊ตฌ์ค')
app.set('ํฌํธ', ํฌํธ)
const ์๋ฒ = http.createServer(์ฑ)
server.listen(ํฌํธ)
server.on('์ค๋ฅ', onError)
server.on('๋ฃ๊ธฐ', onListening)
const mongo = mongoose.connection
mongo.on('์ค๋ฅ', ์ค๋ฅ => { ๋๋ฒ๊ทธ('๋ชฝ๊ณ : ' + error.name) })
mongo.on('์ฐ๊ฒฐ๋จ', () => { ๋๋ฒ๊ทธ('mongo: ์ฐ๊ฒฐ๋จ') })
mongo.on('์ฐ๊ฒฐ ๋๊น', () => { ๋๋ฒ๊ทธ('mongo: ์ฐ๊ฒฐ ๋๊น') })
....
````
DEBUG=blitz* npm run dev
๋ฅผ ์คํํ ๋
````๋ฐฐ์
๋ ธ๋๋ชฌ bin/www
[๋
ธ๋๋ชฌ] 1.18.3
[nodemon] ์ธ์ ๋ ์ง ๋ค์ ์์ํ๋ ค๋ฉด rs
๋ฅผ ์
๋ ฅํ์ญ์์ค.
[๋
ธ๋๋ชฌ] ๋ณด๊ณ ์๋ค: .
[๋
ธ๋๋ชฌ] ์์ node bin/www
blitz ํฌํธ 3000์์ ์์ ๋๊ธฐ ์ค +0ms
๋ธ๋ฆฌ์ธ ๋ชฝ๊ณ : ์ฐ๊ฒฐ๋จ +14ms
(node:10622) DeprecationWarning: collection.ensureIndex๋ ๋ ์ด์ ์ฌ์ฉ๋์ง ์์ต๋๋ค. ๋์ createIndexes๋ฅผ ์ฌ์ฉํ์ญ์์ค.
````
@samuelcecilio ๋์ mongoose.set('useCreateIndex', true)
๋ฅผ bin/www
ํ์ผ๋ก ์ด๋ํ์๊ฒ ์ต๋๊น? ์ต์คํ๋ ์ค ์์ ๋ ์ค์ ํ๊ณ ํ
์คํธํ๊ฒ ์ต๋๋ค.
@samuelcecilio ์ด๊ฒ์ผ๋ก ๋ช ๊ฐ์ง๋ฅผ ๊ฐ์ง๊ณ ๋๋ค๊ฐ ๋ชจ๋ธ์ด ํฌํจ๋ ๊ฒฝ๋ก ํ์ผ์์ useCreateIndex๋ฅผ true๋ก ์ค์ ํด์ผ ํ๋ค๋ ๊ฒ์ ์์์ต๋๋ค. ์ ๊ฒฝ์ฐ์๋ ์ต์คํ๋ ์ค cli ๋๊ตฌ๋ฅผ ์ฌ์ฉํ ํ ์๋ ํ์๋ ์ธ๋ฑ์ค ๊ฒฝ๋ก์์ useCreateIndex๋ฅผ ์ค์ ํด์ผ ํ์ต๋๋ค.
var express = require('express');
var router = express.Router();
const mongoose = require('mongoose');
mongoose.set('useCreateIndex', true);
const Test = mongoose.model('test', { name: {type: String, unique: true }});
/* GET home page. */
router.get('/', function(req, res, next) {
Test.create({ name: 'billy' }).then((doc) => {
return res.status(200).json({ done: true, test: doc.id });
}).catch((e) => {
return res.status(500).json({ err: e });
});
});
module.exports = router;
๋ด๊ฐ ์ป์ ์ธ๋ฑ์ค ๊ฒฝ๋ก์ ์ต์ ์ด ์ค์ ๋์ง ์์ ๊ฒฝ์ฐ :
[nodemon] starting `node bin/www`
version: 5.2.10
(node:17042) DeprecationWarning: collection.ensureIndex is deprecated. Use createIndexes instead.
๋ด๊ฐ ์ป์ ๊ฒฝ๋ก์์ ์ต์ ์ ์ค์ ํ ํ :
[nodemon] starting `node bin/www`
version: 5.2.10
^C
bin/www์์ ์ค์ ์ ์๋ํ์ง๋ง ๊ฒฝ๊ณ ๊ฐ ์ ๊ฑฐ๋์ง ์์์ต๋๋ค. ๊ฒฝ๋ก์ ์ค์ ํด์ผ๋ง ์ฑ๊ณตํ์ต๋๋ค.
~>: curl localhost:3000/
{"done":true,"test":"5b84a4e13ec72e4352475426"}~>:
~>:
๋๋ ์ฌ์ฉ์, ๊ณ ๊ฐ, ๊ณต๊ธ์, ์ฃผ๋ฌธ, ํ๋ชฉ์ ๋ํด ๋ณ๋์ ํ์ผ์ ์ฌ์ฉํฉ๋๋ค.
์ด๋ก ์ธํด ๊ฒฝ๊ณ ๊ฐ ์ค์ง๋์์ต๋๋ค.
๋ชจ๋ธ/์ฌ์ฉ์.js
````js
const addressSchema = ํ์('./์ฃผ์')
const profileSchema = ์๊ตฌ('./ํ๋กํ')
const uuidv4 = ์๊ตฌ('uuid/v4')
const ๋ชฝ๊ตฌ์ค = ์๊ตฌ('๋ชฝ๊ตฌ์ค')
const ์คํค๋ง = mongoose.Schema
mongoose.set('useCreateIndex', ์ฐธ)
const userSchema = ์ ์คํค๋ง({
๋นํ์ฑํ๋จ: { ์ ํ: ๋ถ์ธ, ๊ธฐ๋ณธ๊ฐ: false },
์ญํ : { ์ ํ: ๋ฐฐ์ด, ๊ธฐ๋ณธ๊ฐ: [ '์ด์์คํดํธ' ] },
ID: { ์ ํ: ๋ฌธ์์ด, ๊ณ ์ : true, ํ์: true },
์ฌ์ฉ์ ์ด๋ฆ: { ์ ํ: ๋ฌธ์์ด, ๊ณ ์ : true, ํ์: true },
์ด๋ฆ: { ์ ํ: ๋ฌธ์์ด, ๋๋ฌธ์: true, ํ์: true },
๋น๋ฐ๋ฒํธ: { ์ ํ: ๋ฌธ์์ด, ํ์: true },
๋น๋ฐ: ๋ฌธ์์ด,
ํ๋กํ: ํ๋กํ ์คํค๋ง,
์ฃผ์: addressSchema,
๋ง๋ ๋ ์ง: ๋ ์ง,
์์ : ๋ ์ง
}, {
์ปฌ๋ ์
: '์ฌ์ฉ์'
})
userSchema.pre('์ ์ฅ', ํจ์(๋ค์) {
const ๋ฌธ์ = ์ด๊ฒ
doc.created = Date.now()
doc.modified = Date.now()
doc.secret = uuidv4()
๋ค์()
})
module.exports = mongoose.model('์ฌ์ฉ์', userSchema)
````
๋๋ ๊ทธ๊ฒ์ด ์ผ๋ถ ์ ์ญ ์ค์ ์ด ๋ ๊ฒ์ด๋ผ๊ณ ์๊ฐํ์ง๋ง ๋ถ๋ช ํ ๋ชจ๋ ํ์ผ์ ์ถ๊ฐํด์ผํ์ต๋๋ค.
@samuelcecilio ๋น์ ์ ๋ชฝ๊ตฌ์ค๋ฅผ ์ฌ์ฉ์ ์ ์ ํ์ผ๋ก ๊ฐ์ ์ ์์ต๋๋ค.
const mongoose = require('mongoose')
mongoose.set('useCreateIndex', true);
//etc
module.exports = mongoose
๊ทธ๋ฐ ๋ค์ ๋ชจ๋ ๊ณณ์์ ๋ชฝ๊ตฌ์ค ๋์ const mongoose = require('myMongoose')
๋ํผ๊ฐ ํ์ํฉ๋๋ค. ๊ทธ๊ฒ์ ์๋ง๋ ๋ด๊ฐ 5.2.8 ์ด์์ผ๋ก ์
๊ทธ๋ ์ด๋๋ฅผ ์์ํ ๋ ํด์ผ ํ ์ผ๊ณผ ๋น์ทํ ๊ฒ์
๋๋ค.
์ฌ์ ํ ๋ชจ๋ ํ์ฌ ํ์ผ์ ์์ ํด์ผ ํฉ๋๋ค. models
ํด๋์ ๊ฐ ํ์ผ์ ๋ํด $ require ('mongoose')
๋ฅผ require('myMongoose')
๋ก ๋ฐ๊ฟ๋๋ค. app.js
๋ฐ bin/www
์๋ ๋์ผํ๊ฒ ์ ์ฉ๋ฉ๋๋ค.
์ง๋ฌธ์ ๋ค์๊ณผ ๊ฐ์ต๋๋ค. mongoose
mongoose.set ('useCreateIndex', true)
๋ฅผ ํฌํจํ ํ์๊ฐ ์์ต๋๋ค. ์๋๋ฉด ์ด์ ๋ฒ์ ์ mongo, ๋
ธ๋ ๋ฑ๊ณผ์ ํธํ์ฑ ๋ฌธ์ ๋ก ์ธํด ์ ์์ด ๋ ๊น์?
๋๋ ๋์์ด ๋ชฝ๊ตฌ์ค์ ๋ค์ ์ฃผ์ ๋ฒ์ (์ฆ, 6.0.0 )๊น์ง ์ง๊ธ ๊ทธ๋๋ก ์ ์ง๋ ๊ฒ์ด๋ผ๊ณ ์๊ฐํฉ๋๋ค( ๋ณ์๋ฅผ ๋ด๋ถ ๊ตฌํ์ด ์๋๋ผ ์ค์ ํด์ผ ํจ).
์ง๊ธ์ require('mongoose')
๋ฅผ ํฌํจํ๋ ๋ชจ๋ ํ์ผ์ mongoose.set('useCreateIndex', true)
๋ฅผ ์ถ๊ฐํ์ต๋๋ค. ('./myMongoose')
๋๋ ('./mongoose-custom')
๋ํผ๋ฅผ ์ฌ์ฉํ ์๊ฐ์
๋๋ค. ์ด๋ป๊ฒ ์๊ฐํด?
์ด๊ฒ์ด ๊ธ๋ก๋ฒํด์ผํฉ๋๊น? ํน๊ธ๋ฌธ์ ์ธ๊ฐ์?
๋ชจ๋ธ ์ ์ธ์ด ํฌํจ๋ ๋ชจ๋ ๋จ์ผ ํ์ผ์ mongoose.set('useCreateIndex', true)
๋ฅผ ์ถ๊ฐํ๋ ๊ฒ์ ์ ๋ง ๋ถํธํฉ๋๋ค.
connect
์ต์
์์๋ ์๋ํ๊ฒ ํ๊ฑฐ๋ ์ฐ๊ฒฐํ๊ธฐ ์ ์ ์ค์ ํ์ง ์๋ ์ด์ ๋ ๋ฌด์์
๋๊น?
@samuelcecilio @bricss ๋์ํฉ๋๋ค. ์ ์ฌ์ ์ธ ์๋ฃจ์ ์ ์กฐ์ฌํ๊ธฐ ์ํด ์ด๊ฒ์ ๋ค์ ์ฝ๋๋ค.
์ด๊ฒ์ ๋ชจ๋ ํ์ผ์ ๋ฃ์ ํ์๋ ์์ง๋ง ๋ถํํ๋ ์ง๊ธ ๋น์ฅ์ mongoose.model() ํธ์ถ ์ ์ mongoose.set('useCreateIndex', true)๋ฅผ ๋ฃ์ด์ผ ํ๋ ๊ฒ ๊ฐ์ต๋๋ค. ์คํค๋ง์ ๋ฐ๋๋ก ๋ชจ๋ธ์ ๋ด๋ณด๋ด๋ ๊ฒฝ์ฐ ๊น๋ค๋กญ์ต๋๋ค. ์ด์ ๋ํ ์์ ์ฌํญ์ ์ถ๊ฐํฉ๋๋ค.
๋ฒ์ 5.2.13์ผ๋ก ์ ๊ทธ๋ ์ด๋ํ ํ ๊ฒฝ๊ณ ๋ฅผ ์ค์งํด์ผ ํฉ๋๊น? ๊ฐ์ฌ ํด์
javascript
mongoose.connect(config.dbUri, {
useCreateIndex: true,
useNewUrlParser: true
})
bash
the options [useCreateIndex] is not supported
server: listening on port 3000 +0ms
mongo: Connected +34ms
(node:18457) DeprecationWarning: collection.ensureIndex is deprecated. Use createIndexes instead.
@samuelcecilio useCreateIndex
๋ ์ฐ๊ฒฐ ์ต์
์ด ์๋์ง๋ง mongoose.model()
#$๋ฅผ ํธ์ถํ๊ธฐ ์ ์ mongoose.set('useCreateIndex', true);
๋ฅผ ํธ์ถํ๋ ํ(๋ค๋ฅธ ํ์ผ์์๋) mongoose.model์ ๋ํ ๋ชจ๋ ํ์ ํธ์ถ์ ๋์ฒด๋์ด์ผ ํฉ๋๋ค. mongoose.set()
๋ก ์ค์ ํ ์ต์
์ผ๋ก ์์ ์๋ฅผ ์ฌ์ฉํ์ฌ 5.2.13์ ํ
์คํธํ์ต๋๋ค. ๋์ ๋ด ๊ฒฝ๋ก๊ฐ ์๋ bin/www ํ์ผ์์ mongoose.set('useCreateIndex', true)
๋ฅผ ํธ์ถํ์ต๋๋ค. ์ง๊ธ ์๋ํฉ๋๋ค.
5.2.13์์ ์ฐ๊ฒฐ ํ ๋ฐ ๋ค๋ฅธ ๋ชจ๋ ํ์ผ ์ ์ ์๋ํฉ๋๋ค.
์ด๊ฒ์ ๋ด db.js ํ์ผ์ ์ฐ๊ฒฐ์ ๋๋ค.
// Create the database connection
mongoose.connect(encodeMongoURI(dbURI), options);
mongoose.set('useCreateIndex', true);
๋ณ๋์ ์คํฌ๋ฆฝํธ์ mongo ์ฐ๊ฒฐ์ด ์์ต๋๋ค. ์ด ๋ฐฉ๋ฒ์ผ๋ก mongoose.set('useCreateIndex', true); ์ค์ ๋ก mongo์ ์ฐ๊ฒฐํ๊ธฐ ์ง์ ์ ๋๋ค. ๊ทธ๋ฌ๋ฉด ๋ด ๋ชจ๋ธ ์ ์ธ์ ๋ฃ์ ํ์๊ฐ ์์ต๋๋ค.
@LucHighwalker ์ ์ ์์ ์ด๋ฅผ ์ํํ๋ ์ฌ๋ฐ๋ฅธ ๋ฐฉ๋ฒ์
๋๋ค. ์ด์์ ์ผ๋ก๋ mongoose.connect()
ํธ์ถ ์ง์ ์ ์ด๋ฌํ ๋ชจ๋ ์ ์ญ ์ต์
์ ๋ฐฐ์นํฉ๋๋ค.
๊ธฐ๋ฅ์ ์ฐจ์ด๊ฐ ์๋์?
mongoose.connect(encodeMongoURI(dbURI), options);
mongoose.set('useCreateIndex', true);
๊ทธ๋ฆฌ๊ณ
mongoose.set('useCreateIndex', true);
mongoose.connect(encodeMongoURI(dbURI), options);
? ๋ ๋ค 5.2.17์์ ์ ์๋ํ๋ ๊ฒ์ฒ๋ผ ๋ณด์ด๊ธฐ ๋๋ฌธ์
mongoose.connect(config.dbUri, {
useCreateIndex: true,
useNewUrlParser: true
})
์ต์ ๋ฒ์ ์์ ์๋
์ข์, ๋๋ @types/mongoose๊ฐ ๊ทธ ๋ค์ ์ผ๋ถ ๋ฒ์ ์ด๋ผ๊ณ ์๊ฐํฉ๋๋ค(์์ง typescript์์๋ ์๋ํ์ง ์์ต๋๋ค).
mongoose.connect(url, {
useNewUrlParser: true,
autoIndex: false
})
@Dionesio ์ ๋๋ต์ ๋์๊ฒ ์์์๋ฅผ ์ผ์ต๋๋ค. ๊ฐ์ฌ ํด์!
mongoose.connect("mongodb://localhost:27017/test", {useNewUrlParser: true});
mongoose.set('useCreateIndex', ์ฐธ);
์ด๊ฒ์ ๋ด ๋ชจ๋ ์ฌ์ฉ ์ค๋จ ๊ฒฝ๊ณ ๋ฅผ ํด๊ฒฐํ์ต๋๋ค.
@samuelcecilio ์ด๊ฒ์ผ๋ก ๋ช ๊ฐ์ง๋ฅผ ๊ฐ์ง๊ณ ๋๋ค๊ฐ ๋ชจ๋ธ์ด ํฌํจ๋ ๊ฒฝ๋ก ํ์ผ์์ useCreateIndex๋ฅผ true๋ก ์ค์ ํด์ผ ํ๋ค๋ ๊ฒ์ ์์์ต๋๋ค. ์ ๊ฒฝ์ฐ์๋ ์ต์คํ๋ ์ค cli ๋๊ตฌ๋ฅผ ์ฌ์ฉํ ํ ์๋ ํ์๋ ์ธ๋ฑ์ค ๊ฒฝ๋ก์์ useCreateIndex๋ฅผ ์ค์ ํด์ผ ํ์ต๋๋ค.
var express = require('express'); var router = express.Router(); const mongoose = require('mongoose'); mongoose.set('useCreateIndex', true); const Test = mongoose.model('test', { name: {type: String, unique: true }}); /* GET home page. */ router.get('/', function(req, res, next) { Test.create({ name: 'billy' }).then((doc) => { return res.status(200).json({ done: true, test: doc.id }); }).catch((e) => { return res.status(500).json({ err: e }); }); }); module.exports = router;
๋ด๊ฐ ์ป์ ์ธ๋ฑ์ค ๊ฒฝ๋ก์ ์ต์ ์ด ์ค์ ๋์ง ์์ ๊ฒฝ์ฐ :
[nodemon] starting `node bin/www` version: 5.2.10 (node:17042) DeprecationWarning: collection.ensureIndex is deprecated. Use createIndexes instead.
๋ด๊ฐ ์ป์ ๊ฒฝ๋ก์์ ์ต์ ์ ์ค์ ํ ํ :
[nodemon] starting `node bin/www` version: 5.2.10 ^C
bin/www์์ ์ค์ ์ ์๋ํ์ง๋ง ๊ฒฝ๊ณ ๊ฐ ์ ๊ฑฐ๋์ง ์์์ต๋๋ค. ๊ฒฝ๋ก์ ์ค์ ํด์ผ๋ง ์ฑ๊ณตํ์ต๋๋ค.
์ปฌ๋ง ๋ก์ปฌ ํธ์คํธ์ ์ถ๋ ฅ
~>: curl localhost:3000/ {"done":true,"test":"5b84a4e13ec72e4352475426"}~>: ~>:
๊ฐ์ฌํฉ๋๋ค - ์ถ๊ฐ mongoose.set('useCreateIndex', true); ๋ด ๋ฌธ์ ๋ฅผ ํด๊ฒฐํ์ต๋๋ค
์ด ๋ฌธ์ ๋ฅผ ์ ๊ทธ๊ฒ ์ต๋๋ค. ๋์ค์ ์ฐธ์กฐ ํ๋ ค๋ฉด ๋ฌธ์์์ ์ฌ์ฉ ์ค๋จ ๊ฐ์ด๋๋ฅผ ์ฐธ์กฐํ์ธ์.
๊ฐ์ฅ ์ ์ฉํ ๋๊ธ
๋ฒ์ 5.2.10์ผ๋ก ์ ๊ทธ๋ ์ด๋ํ ํ. ์๋ ์ต์ ์ค ๊ฒฝ๊ณ ๋ฅผ ์ค์งํด์ผ ํ๋ ์ต์ ์ด ์์ต๋๊น?
js mongoose.connect(config.dbUri, { useCreateIndex: true, useNewUrlParser: true })
๋๋
js mongoose.set('useCreateIndex', true) mongoose.connect(config.dbUri, { useNewUrlParser: true })
์ฌ๊ธฐ์์ ์๋ํ์ง ์์์ต๋๋ค. (์ ๊ฐ ์๋ชปํ๊ฑฐ๋ผ๋ฉด ์ฃ์กํฉ๋๋ค)