【发布时间】:2011-12-04 07:25:57
【问题描述】:
我的主文档中有一个嵌入的图像文档,我可以按如下方式对其进行更新。每次更新时,它只是覆盖现有图像而不将其添加到现有图像中。我尝试使用“{images.push: image}”,但这不起作用。语法是什么?我不确定我是否能够解释这个问题。如果没有,请告诉我是否需要在此处添加更多信息。
var image = {
img : new_file_name,
orig_img_name : files.source.filename,
caption : fields.message,
upload_date : new Date()
};
RentModel.update({'facebook_id':fb_id, 'prop_location.lat':lat, 'prop_location.lng':lng}, {'images':image}, function(err, docs){
if(err) {
console.log("Error during friends update");
throw err;
}
console.log('image updated to database', new_file_name);
});
【问题讨论】: