我越來越deprecatingWarning即使我有:DeprecatingWarning:與貓鼬
mongoose.Promise = global.Promise;
var express = require('express');
var responseTime = require('response-time');
var mongoose = require('mongoose');
var User = require('../models/user');
var Task = require('../models/task');
var Rating = require('../models/rating');
var Skill = require('../models/skill');
var Match = require('../models/match');
var UserSkill = require('../models/user_skill');
var app = express();
var bodyParser = require('body-parser');
var PORT_NUMBER = 3000;
// response-time middleware (adds X-Response-Header to responses)
app.use(responseTime());
//
mongoose.Promise = global.Promise;
mongoose.connect('mongodb://useyourown');
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({
extended: true
}));
app.post('/create', function(req,res){
let newTask = new Task();
newTask.name = req.body.name;
newTask.experience = req.body.experience;
newTask.user_id = req.body.user_id;
newTask.rating = req.body.rating;
newTask.save(function(err, task){
if(err){
return err;
}
else{
console.log("Task saved: " + task.name);
}
res.redirect('hearbeat');
});
});
現在,當我與郵差測試這個我的控制檯給我這個錯誤:
DeprecationWarning: Mongoose: mpromise (mongoose's default promise library) is deprecated, plug in your own promise library instead: http://mongoosejs.com/docs/promises.html
,正因爲如此,它無法正常工作。 有很多人有這種錯誤,但添加Promise爲他們解決了這個問題。我不明白爲什麼它現在爲我工作。
謝謝,我不知道我必須把它放在任何地方。 – user3450754