Apakah Anda ingin meminta fitur atau melaporkan bug ?
Bug
Bagaimana perilaku saat ini?
Pada skrip di bawah ini, ketika kita menarik dokumen induk, kita melihat bahwa child
kembali sebagai {}
, tetapi child2
kembali sebagai { field: 'test'}
meskipun faktanya bahwa ChildSchema.field
memiliki select: false
.
Saat melihat debugger, hanya child.field
yang dipilih dan child2.field
tidak.
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);
}
});
Sebutkan versi node.js, mongoose, dan MongoDB Anda.
4.11.8
terima kasih untuk skrip repro lengkap, ini terlihat seperti bug
Memberi @wlingke lencana imajiner untuk Penemu Bug Mongoose Terbaik Tahun Ini, 2017 ™ 🐜
@wlingke , menemukan semua bug paling halus di luwak sejak 2014: rocket:: 1st_place_medal:
Komentar yang paling membantu
@wlingke , menemukan semua bug paling halus di luwak sejak 2014: rocket:: 1st_place_medal: