无法通过mongoose包含和排除查询字段

我有一些架构和查询如下:

mongoose.model('mymodel').find({}, 'one -two -__v', function(err,docs){}); 

我希望文档只能返回字段“一”。 总是忽略字段'两',rest一下。 然后我得到以下错误:

 You cannot currently mix including and excluding fields. Contact us if this is an issue. 

我正在dynamic生成字段string以包含或排除所需的字段。

如何摆脱错误。

这实际上与mongoose没有任何关系。 mongo本身存在“限制”。

从collection.find文档

除了_id字段外,投影不能同时包含include和exclude规范。 在明确包含字段的投影中, _id字段是唯一可以明确排除的字段。


你要么包括, 要么排除,你不能同时做两个,(_ _id除外)

只select_idone

 'one' 

select除two以外的所有字段

 '-two' 

例外:只selectone 没有 _id

 'one -_id'