Reputation: 1498
I've the following code:
const Box = mongoose.model("box", {
_id: mongoose.Schema.ObjectId,
mac: String
});
Box.findOne({ mac: "MACADDRESS" }, function (err, data) {
data._doc.name = "box 2";
data.save(function (err) {
if (err) {
console.log(err);
return;
}
});
});
I can't identify why the document is not saving. Anyone can help me?
Upvotes: 0
Views: 127
Reputation: 537
Your model definition has mac
in the attribute so it may go like this
Box.findOne({ mac: "MACADDRESS" }, function (err, data) {
data.mac = "box 2";
data.save(function (err) {
if (err) {
console.log(err);
return;
}
});
});
Upvotes: 3