无法从JSON对象中删除字段-节点JS
我有一条生成PDF的路线无法从JSON对象中删除字段-节点JS,json,node.js,mongoose,Json,Node.js,Mongoose,我有一条生成PDF的路线 featureRoutes.route('/report/').get(function (req, res) { Feature.find(function (err,features){ if(err){ console.log(err); } else { pdf.create(features.toString()).toStream(function (err, stream) { if (err) return res.send(err); res
featureRoutes.route('/report/').get(function (req, res) {
Feature.find(function (err,features){
if(err){
console.log(err);
}
else {
pdf.create(features.toString()).toStream(function (err, stream) {
if (err) return res.send(err);
res.type('pdf');
stream.pipe(res);
});
}
});
});
pdf的内容是一个JSON对象,如下所示
[ { _id: 5ad5ddddcd054b2b5b20143c,
name: 'Project sidebar',
description: '<p>The project sidebar that we previewed in <a href="https://confluence.atlassian.com/jira/jira-6-4-release-notes-678561444.html">JIRA 6.4</a> is here to stay. We built this new navigation experience to make it easier for you to find what you need in your projects. It's even better, if you are using JIRA Agile: your backlog, sprints, and reports are now just a click away. If you've used the sidebar with JIRA Agile before, you'll notice that cross-project boards, which include multiple projects, now have a project sidebar as well — albeit a simpler version.</p>\n',
__v: 0 }
及
但是生成的PDF仍然包含id和_V字段
如何正确删除节点中的字段?我在Feature.find的末尾用.select限制了字段
.select("-__v -_id");
可能是数组或json的重复项。从代码上看,它看起来像是数组中的json?可能是
删除功能[0]。\u id
@Macintosh\u 89-它不会删除任何项目,我正在使用节点8.11回答:创建时如何执行?请参考,它可能会有所帮助。
delete features.__V
.select("-__v -_id");