Unable to fetch bulkwriteresult result upon update to mongoose 5 #7225
Closed
Description
Do you want to request a feature or report a bug?
bug
What is the current behavior?
Upon updating to mongoose 5 from mongoose 4, bulkwriteresult object is unable to retrieve nMatched, nModified, etc. It is now undefined
If the current behavior is a bug, please provide the steps to reproduce.
const bulkWriteResult = await Student.bulkWrite(
[...bulkAddDeleteOps, ...bulkUpdateOps, ...bulkDeleteOps],
{ ordered: true, w: 1 },
(err, result) => {
if (err) throw err;
},
);
// this used to work before package upgrade
bulkWriteStatus = {
matched: bulkWriteResult.nMatched,
modified: bulkWriteResult.nModified,
ok: bulkWriteResult.ok,
};
// when I log `bulkWriteResult` in console, it shows this
BulkWriteResult {
result:
{ ok: 1,
writeErrors: [],
writeConcernErrors: [],
insertedIds: [],
nInserted: 0,
nUpserted: 0,
nMatched: 28,
nModified: 28,
nRemoved: 0,
upserted: [] },
insertedCount: 0,
matchedCount: 28,
modifiedCount: 28,
deletedCount: 0,
upsertedCount: 0,
upsertedIds: {},
insertedIds: {},
n: 0 }
What is the expected behavior?
Work as-is the current version
Please mention your node.js, mongoose and MongoDB version.
node: 8.9.4
mongoose: 5.3.10
mongodb: 3.6.4