I have a schema as seen here:
var schema2 = new mongoose.Schema({
email: "string",
name: "string",
projectname: "string"
});
And a model here:
var newproject = mongoose.model("pages", schema);
Then I say what I want to save:
var page = new newproject({
email: req.body["userid"],
name: req.body["statuspagename"],
projectname: req.body["project"]
});
Then save it:
page.save(function(err) {
if (err) {
console.log(err);
} else {
console.log("page created!");
}
res.send("Page created!");
});
But it doesn’t save the ‘projectname’. If I console.log(page);
it also doesn’t show in that. How come ‘projectname’ isn’t showing?
Found it was that I used schema instead of schema2 when defining the model