機能をリクエストしバグを報告しますか?
バグ
現在の動作は何ですか?
以下のスクリプトでは、親ドキュメントをプルすると、 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
完全な再現スクリプトをありがとう、これはバグのように見えます
@wlingkeに2017™ベストマングースバグファインダーオブ
@ wlingke 、2014年以降のマングースの最も微妙なバグをすべて見つけました:rocket :: 1st_place_medal:
最も参考になるコメント
@ wlingke 、2014年以降のマングースの最も微妙なバグをすべて見つけました:rocket :: 1st_place_medal: