Skip to main content
Improved formatting
Source Link
Tyler2P
  • 2.4k
  • 30
  • 26
  • 34

iI have same issue, after a while trial&errortrial & error, iI found out adding a checking truthy ( if (result)if (result) ) works for me

 const result = await Package.bulkWrite(   options,   { session }  )  for (const key in packageBundle) {   if (Object.prototype.hasOwnProperty.call(packageBundle, key)) {   packageBundle[key].custom_id_string = 'CAB' + packageBundle[key].custom_id.toLocaleString('en-US', {   minimumIntegerDigits: 14,   useGrouping: false   })   }  } if (result) await session.commitTransaction() else await session.abortTransaction() 

Can't explain why, but it's worth to try

i have same issue, after a while trial&error, i found out adding a checking truthy ( if (result) ) works for me

 const result = await Package.bulkWrite(   options,   { session }  )  for (const key in packageBundle) {   if (Object.prototype.hasOwnProperty.call(packageBundle, key)) {   packageBundle[key].custom_id_string = 'CAB' + packageBundle[key].custom_id.toLocaleString('en-US', {   minimumIntegerDigits: 14,   useGrouping: false   })   }  } if (result) await session.commitTransaction() else await session.abortTransaction() 

Can't explain why, but it's worth to try

I have same issue, after a while trial & error, I found out adding a checking truthy ( if (result) ) works for me

const result = await Package.bulkWrite( options, { session } ) for (const key in packageBundle) { if (Object.prototype.hasOwnProperty.call(packageBundle, key)) { packageBundle[key].custom_id_string = 'CAB' + packageBundle[key].custom_id.toLocaleString('en-US', { minimumIntegerDigits: 14, useGrouping: false }) } } if (result) await session.commitTransaction() else await session.abortTransaction() 

Can't explain why, but it's worth to try

Source Link
Bao N
  • 41
  • 2

i have same issue, after a while trial&error, i found out adding a checking truthy ( if (result) ) works for me

 const result = await Package.bulkWrite( options, { session } ) for (const key in packageBundle) { if (Object.prototype.hasOwnProperty.call(packageBundle, key)) { packageBundle[key].custom_id_string = 'CAB' + packageBundle[key].custom_id.toLocaleString('en-US', { minimumIntegerDigits: 14, useGrouping: false }) } } if (result) await session.commitTransaction() else await session.abortTransaction() 

Can't explain why, but it's worth to try