5
Mongoose.js 3.1.2에서 일부 내용을 업데이트하려고하는데이 두 함수가 작동하지 않습니다. 어떤 아이디어? 덕분에 ...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");
});
});
}
내 스키마는 다음과 같은 :
contentSchema = new Schema(
title: String,
slug: String,
body: String,
snippets: Object
);
오, 와우, 당신은 완전히 내 마음을 불어 넣어 주셔서 감사합니다. D – red
예! 나는 그것을 어떻게 놓쳤는가? 감사 빌 – Pardoner
당신은 내 영웅입니다. – ehaydenr