I'm getting this error message when running node file.js in the Mac terminal. My terminal doesn't have any special config. I tried adding "mongoose.Promise = global.Promise" before "mongoose.connect...".
DeprecationWarning: Mongoose: mpromise (mongoose's default promise library) is deprecated, plug in your own promise library instead: http://mongoosejs.com/docs/promises.html
Here's the source code:
var Product = require('../models/product');
var mongoose = require('mongoose');
mongoose.Promise = global.Promise;
mongoose.connect('localhost:27017/shopping');
var products = [
new Product({
imagePath: 'https://upload.wikimedia.org/wikipedia/en/5/5e/Gothiccover.png',
title: 'Gothic 5 Video Game',
description: 'Awesome Game!!!!',
price: 10
}),
new Product({
imagePath: 'https://upload.wikimedia.org/wikipedia/en/5/5e/Gothiccover.png',
title: 'Gothic 4 Video Game',
description: 'Also Awesome Game!!!!',
price: 20
}),
new Product({
imagePath: 'https://upload.wikimedia.org/wikipedia/en/5/5e/Gothiccover.png',
title: 'Gothic 3 Video Game',
description: 'best game ever!!!!',
price: 15
}),
new Product({
imagePath: 'https://upload.wikimedia.org/wikipedia/en/5/5e/Gothiccover.png',
title: 'Gothic 2 Video Game',
description: 'top notch!!!',
price: 50
})
];
var done = 0;
for (var i = 0; i < products.length; i++) {
products[i].save(function(err, result){
done++;
if (done === products.length) {
exit();
}
});
}
function exit() {
mongoose.disconnect();
}