我有一个表示日历数据的JSON对象。我坚持如何,或者是否可以添加一个create方法来插入基于键值的新数据。
这是我的架构
year: {
August: [
{
day: String,
title: String,
summary: String,
description: String
}
],
September: [
{
day: String,
title: String,
summary: String,
description: String
}
]
}
});
我希望能够根据Key值创建一个新日期,Key是月份。
{
_id: "53d069cbea21639a67b5c64b"
__v: 0
-year: {
-September: [
-{
day: "9 sep"
title: "sep title"
summary: "sep summ"
_id: "53d069cbea21639a67b5c64c"
}
],
-August: [
-{
day: "9"
title: "Dave Ramsey's Financial Peace University"
summary: "Financial Peace University (FPU) is a biblically-based, life-changing program that teaches people how to make wise decisions with money. You will be empowered with the practical skills and confidence needed..."
_id: "53d069ccea21639a67b5c651"
}
-{
day: "17"
title: "Divorce & Beyond Seminar"
summary: "If you are separated from your spouse, going through a divorce or are divorced, we encourage you to seek support. We understand the feelings of guilt, rejection, fear, confusion, isolation,..."
_id: "53d069ccea21639a67b5c650"
}
]
}
}
这是我当前的创建方法。也许这里的一切都很好,我的工作只需要在角度方面完成......
module.exports.create = function (req, res) {
var cal = new Cal(req.body);
cal.save(function(err, result) {
if (err)
res.send(err);
res.json(result);
});
}
我目前正在邮递员中使用新的_id和空值返回新对象。
{
__v: 0
_id: "53ed6aa775e54f91b7362788"
-year: {
September: [ ]
August: [ ]
}
}