5
Tôi đang cố gắng cập nhật một số nội dung trong Mongoose.js 3.1.2 và tôi không thể có được hai chức năng này để hoạt động. Bất kỳ ý tưởng tại sao? Cảm ơn ...khắc phục sự cố trong Mongoose 3
function(req, res) {
Content.findById(req.body.content_id, function(err, content) {
// add snippet to content.snippets
content.snippets[req.body.snippet_name] = req.body.snippet_value;
content.save(function(err) {
res.json(err || content.snippets);
});
}
}
function(req, res) {
Content.findById(req.body.content_id, function(err, content) {
// delete snippets
delete content.snippets[req.body.snippet_name];
//content.snippets[req.body.snippet_name] = undefined; <-- doesn't work either
content.save(function(err) {
res.json(err || "SUCCESS");
});
});
}
schema của tôi trông giống như sau:
contentSchema = new Schema(
title: String,
slug: String,
body: String,
snippets: Object
);
Oh wow, bạn hoàn toàn thổi tâm trí của tôi, cảm ơn vì điều này: D – red
Có! Làm thế nào tôi đã bỏ lỡ nó. Cảm ơn Bill – Pardoner
Bạn là anh hùng của tôi. – ehaydenr