您是否要请求功能或报告错误?
漏洞
目前的行为是什么?
在下面的脚本中,当我们提取父文档时,我们看到child
返回为{}
,但是child2
返回为{ field: 'test'}
尽管事实上ChildSchema.field
具有select: false
。
在查看调试器时,仅选择了child.field
而没有选择child2.field
。
const mongoose = require('mongoose');
mongoose.connect('mongodb://127.0.0.1/test');
const db = mongoose.connection;
db.once('open', async () => {
try {
const ChildSchema = new mongoose.Schema({
field: {
type: String,
select: false,
},
_id: false,
}, { id: false });
const ParentSchema = new mongoose.Schema({
child: ChildSchema,
child2: ChildSchema,
});
const Parent = mongoose.model('Parent', ParentSchema);
const ogParent = new Parent();
ogParent.child = { field: 'test' };
ogParent.child2 = { field: 'test' };
await ogParent.save();
const foundParent = await Parent.findById(ogParent._id).exec();
console.log(foundParent);
db.close();
} catch (e) {
console.log(e);
}
});
请提及您的node.js,mongoose和MongoDB版本。
4.11.8
感谢完整的repro脚本,这看起来像个bug
为@wlingke颁发假想徽章,以纪念2017年年度最佳猫鼬错误查找器🐜
@wlingke ,发现了自2014年以来猫鼬中所有最细微的错误:rocket :: 1st_place_medal:
最有用的评论
@wlingke ,发现了自2014年以来猫鼬中所有最细微的错误:rocket :: 1st_place_medal: