5
Próbuję zaktualizować niektóre treści w Mongoose.js 3.1.2 i nie mogę uzyskać tych dwóch funkcji do pracy. Jakieś pomysły, dlaczego? Dzięki ...Zapisywanie problemów w 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");
});
});
}
Mój schemat wygląda mniej więcej tak:
contentSchema = new Schema(
title: String,
slug: String,
body: String,
snippets: Object
);
Och, wow, całkowicie mnie roztrzęsiłeś, dzięki za to: D – red
Tak! Jak to przegapiłem. Dzięki, Bill – Pardoner
Jesteś moim bohaterem. – ehaydenr