Article.findByIdAndUpdate(req.body.aid,{$set:{title:req.body.title,tags:req.body.tags,uid:req.body.uid,pv:req.body.pv}},function(err,Article){
if(!err){
if(!req.body.article){
Article.findByIdAndUpdate(Article._id,{$push:{Article:{collections:{
uid: req.body.uid,
time: req.body.time,
article: req.body.article.split("<!--p-->"),
}}}},function(err,Article){
if(!err){
res.send('数据更新成功')
}
});
}
res.send('数据更新成功')
}
});
{
"uid" : "4hg56f4hf",
"title" : "f5sdf456sd",
"tags" : "dfs,f,s,sdg,ds,gs,g,s,dg",
"pv" : 0,
"_id" : ObjectId("52da4efb5007465c1c16006e"),
"comments" : [],
"collections" : [{
"uid" : "4hg56f4hf",
"time" : new Date("2/1/1970 18:17:36"),
"_id" : ObjectId("52da4efb5007465c1c16006f"),
"article" : ["j4f5gh4564h\\r\\nf5<!--page-->6sd4f564sf6h4s64h6sdhsh56sd26dsh56sh65s6+h56+sd5h5sd6+h56+<!--page-->sd5gf65f6h5fg6j4f4h5kjh54jh5f4f418451544156154845oiuyyurjkjhgfsdadfghjkjhgfdsasdfghjklkjhgfd"]
}],
"__v" : 0
}
##怎么在collections数组中添加一个集
{
uid: req.body.uid,
time: req.body.time,
article: req.body.article.split("<!--p-->"),
}