convertDocuments(collectionName, document, overwriteParams) {
    const Model = this.growiBridgeService.getModelFromCollectionName(collectionName);
    const schema = (Model != null) ? Model.schema : null;
    const convertMap = this.convertMap[collectionName];

    const _document = {};

    // not Mongoose Model
    if (convertMap == null) {
      // apply keepOriginal to all of properties
      Object.entries(document).forEach(([propertyName, value]) => {
        _document[propertyName] = this.keepOriginal(value, { document, propertyName });
      });
    }
    // Mongoose Model
    else {
      // assign value from documents being imported
      Object.entries(convertMap).forEach(([propertyName, convertedValue]) => {
        const value = document[propertyName];

        // distinguish between null and undefined
        if (value === undefined) {
          return; // next entry
        }

        const convertFunc = (typeof convertedValue === 'function') ? convertedValue : null;
        _document[propertyName] = (convertFunc != null) ? convertFunc(value, { document, propertyName, schema }) : convertedValue;
      });
    }

    // overwrite documents with custom values
    Object.entries(overwriteParams).forEach(([propertyName, overwriteValue]) => {
      const value = document[propertyName];

      // distinguish between null and undefined
      if (value !== undefined) {
        const overwriteFunc = (typeof overwriteValue === 'function') ? overwriteValue : null;
        _document[propertyName] = (overwriteFunc != null) ? overwriteFunc(value, { document: _document, propertyName, schema }) : overwriteValue;
      }
    });

    return _document;
  }
/**
   * execute unorderedBulkOp and ignore errors
   *
   * @memberOf ImportService
   * @param {string} collectionName
   * @param {object} document document being imported
   * @param {object} overwriteParams overwrite each document with unrelated value. e.g. { creator: req.user }
   * @return {object} document to be persisted
   */
execute unorderedBulkOp and ignore errors
@memberOf ImportService
@param {string} collectionName
@param {object} document document being imported
@param {object} overwriteParams overwrite each document with unrelated value.
execute unorderedBulkOp and ignore errors @memberOf ImportService @param { string } collectionName @param { object } document document being imported @param { object } overwriteParams overwrite each document with unrelated value .
convertDocuments(collectionName, document, overwriteParams) {
    const Model = this.growiBridgeService.getModelFromCollectionName(collectionName);
    const schema = (Model != null) ? Model.schema : null;
    const convertMap = this.convertMap[collectionName];
    const _document = {};
    if (convertMap == null) {
      Object.entries(document).forEach(([propertyName, value]) => {
        _document[propertyName] = this.keepOriginal(value, { document, propertyName });
      });
    }
    else {
      Object.entries(convertMap).forEach(([propertyName, convertedValue]) => {
        const value = document[propertyName];
        if (value === undefined) {
          return; 
        }
        const convertFunc = (typeof convertedValue === 'function') ? convertedValue : null;
        _document[propertyName] = (convertFunc != null) ? convertFunc(value, { document, propertyName, schema }) : convertedValue;
      });
    }
    Object.entries(overwriteParams).forEach(([propertyName, overwriteValue]) => {
      const value = document[propertyName];
      if (value !== undefined) {
        const overwriteFunc = (typeof overwriteValue === 'function') ? overwriteValue : null;
        _document[propertyName] = (overwriteFunc != null) ? overwriteFunc(value, { document: _document, propertyName, schema }) : overwriteValue;
      }
    });
    return _document;
  }
convertDocuments ( collectionName , document , overwriteParams ) { const Model = this . growiBridgeService . getModelFromCollectionName ( collectionName ) ; const schema = ( Model != null ) ? Model . schema : null ; const convertMap = this . convertMap [ collectionName ] ; const _document = { } ; if ( convertMap == null ) { Object . entries ( document ) . forEach ( ( [ propertyName , value ] ) => { _document [ propertyName ] = this . keepOriginal ( value , { document , propertyName } ) ; } ) ; } else { Object . entries ( convertMap ) . forEach ( ( [ propertyName , convertedValue ] ) => { const value = document [ propertyName ] ; if ( value === undefined ) { return ; } const convertFunc = ( typeof convertedValue === 'function' ) ? convertedValue : null ; _document [ propertyName ] = ( convertFunc != null ) ? convertFunc ( value , { document , propertyName , schema } ) : convertedValue ; } ) ; } Object . entries ( overwriteParams ) . forEach ( ( [ propertyName , overwriteValue ] ) => { const value = document [ propertyName ] ; if ( value !== undefined ) { const overwriteFunc = ( typeof overwriteValue === 'function' ) ? overwriteValue : null ; _document [ propertyName ] = ( overwriteFunc != null ) ? overwriteFunc ( value , { document : _document , propertyName , schema } ) : overwriteValue ; } } ) ; return _document ; }
execute unorderedBulkOp and ignore errors
 @memberOf ImportService
 @param {string} collectionName
 @param {object} document document being imported
 @param {object} overwriteParams overwrite each document with unrelated value.
execute unorderedBulkOp and ignore errors @memberOf ImportService @param { string } collectionName @param { object } document document being imported @param { object } overwriteParams overwrite each document with unrelated value .
// not Mongoose Model // apply keepOriginal to all of properties // Mongoose Model // assign value from documents being imported // distinguish between null and undefined // next entry // overwrite documents with custom values // distinguish between null and undefined