I am using WebStorm and I am getting an error that I cannot understand. Node.js + MongoDB.
var mongoose = require('mongoose');
mongoose.Promise = global.Promise;
mongoose.connect(' mongodb://localhost:27017/TodoApp');
var Todo = mongoose.model('Todo', {
text: {
type: String
},
completed: {
type: Boolean
},
completedAt: {
type: Number
}
});
var newTodo = new Todo({
text: 'Cook dinner'
});
The problem is in this block:
newTodo.save().then((doc) => {
console.log('Saved todo', doc);
}, (e) => {
console.log('Unable to save todo')
})
PS: The code is working fine.
source
share