save () method of mongoose not saved

0

I have the following problem:

When calling the mongoose save method it seems to be doing nothing. The code for the save is as follows:

var newProjects = new projectModel({
    "teste":"teste"
});
newProjects.save(function (err){
    if(err){
        console.log("Erro");
        return;
    }else {
        console.log("Funcionou");
        return;
    };
});   
console.log("Passou")

What happens is that it never logs the "Error" or "It worked" messages, but logs the "Passed" message, and also does not create the collection in MongoDB. As this is the first time the save of this model is executed, I believe that the creation should be done.

The ProjectModel variable is initialized like this: var projectModel = mongoose.model('Projects');

And the collection modeling is as follows:

var mongoose = require("mongoose");

var projectsSchema = new mongoose.Schema({
    teste: {type: String, required: true}
});

mongoose.model('Projects', projectsSchema);

Any idea what might be causing the problem?

    
asked by anonymous 24.05.2017 / 22:51

0 answers