我在一系列文件中恢复:
exports.dropWithDocumentId = function(req,res) {
Flux.loadByDocumentId(req.params.id,function(err,flux){
if (err) { res.sendStatus(500); return; }
console.log(flux) ;
res.json(flux);
});
}
,它给了我以下结果:
[ { _id: 55a37838363ea5c00913cb4b,
texte: 'testtt',
nomUtilisateur: 'user1',
formation: 5587d9b96c861a800f6d6563,
diplome: 5587e7acb90c3e581a0393ac,
__v: 2,
tags: [],
documents:
[ { document: 55a37824363ea5c00913cb4a,
modele: 'Fichier',
_id: 55a37838363ea5c00913cb4c } ],
type: 1,
commentaires:
[ { _id: 55a3790ff6c0f588056b5b82,
user: 5587e7acb90c3e581a0393ac,
prest: 5587d9b96c861a800f6d6563,
texte: 'aaaaaaaaaaaa',
date: Mon Jul 13 2015 10:38:39 GMT+0200 (Paris, Madrid (heure d'été))
,
{ _id: 55a37906f6c0f588056b5b80,
user: 5587e7acb90c3e581a0393ac,
prest: 5587d9b96c861a800f6d6563,
texte: 'aqqqqqq',
date: Mon Jul 13 2015 10:38:30 GMT+0200 (Paris, Madrid (heure d'été))
],
date: Mon Jul 13 2015 10:35:04 GMT+0200 (Paris, Madrid (heure d'été)) } ]
现在我要从ID :
中删除此集合中的所有文档exports.dropWithDocumentId = function(req,res) {
Flux.loadByDocumentId(req.params.id,function(err,flux){
if (err) { res.sendStatus(500); return; }
flux.forEach( function (doc) {
doc.remove();
});
//console.log(flux.type) ;
res.json(flux);
});
}
但它不起作用!! 帮助我