Uname: Linux business55.web-hosting.com 4.18.0-553.lve.el8.x86_64 #1 SMP Mon May 27 15:27:34 UTC 2024 x86_64
Software: LiteSpeed
PHP version: 8.1.31 [ PHP INFO ] PHP os: Linux
Server Ip: 162.213.251.212
Your Ip: 18.216.232.215
User: allssztx (535) | Group: allssztx (533)
Safe Mode: OFF
Disable Function:
NONE

name : bulkSaveIncompleteError.js
/*!
 * Module dependencies.
 */

'use strict';

const MongooseError = require('./mongooseError');


/**
 * If the underwriting `bulkWrite()` for `bulkSave()` succeeded, but wasn't able to update or
 * insert all documents, we throw this error.
 *
 * @api private
 */

class MongooseBulkSaveIncompleteError extends MongooseError {
  constructor(modelName, documents, bulkWriteResult) {
    const matchedCount = bulkWriteResult?.matchedCount ?? 0;
    const insertedCount = bulkWriteResult?.insertedCount ?? 0;
    let preview = documents.map(doc => doc._id).join(', ');
    if (preview.length > 100) {
      preview = preview.slice(0, 100) + '...';
    }

    const numDocumentsNotUpdated = documents.length - matchedCount - insertedCount;
    super(`${modelName}.bulkSave() was not able to update ${numDocumentsNotUpdated} of the given documents due to incorrect version or optimistic concurrency, document ids: ${preview}`);

    this.modelName = modelName;
    this.documents = documents;
    this.bulkWriteResult = bulkWriteResult;
    this.numDocumentsNotUpdated = numDocumentsNotUpdated;
  }
}

Object.defineProperty(MongooseBulkSaveIncompleteError.prototype, 'name', {
  value: 'MongooseBulkSaveIncompleteError'
});

/*!
 * exports
 */

module.exports = MongooseBulkSaveIncompleteError;
© 2025 GrazzMean-Shell