loadPartitionData(collection, group, jsonFile) {
    check(collection, Mongo.Collection);
    check(group, Match.Optional(String));
    check(jsonFile, Match.Optional(String)); 


    let tenantId = group || Core.getDefaultTenantId();

    // prevent import if existing collection data for the partition
    if (tenantId) {
      Partitioner.bindGroup(tenantId, function(){ 
        if (collection.find().count() > 0) {
          return false;
        }
    
        let json = null;
        let result = null;
    
        Core.Log.debug(
          `Loading initialisation data for ${collection._name} in tenant ${tenantId}`);
        // if jsonFile was path wasn't provided
        // we'll assume we're loading collection data
        if (!jsonFile) {
          json = EJSON.parse(Assets.getText("data/" + collection._name +
            ".json"));
        } else {
          json = EJSON.parse(jsonFile); 
        }
         
        let totalItems = Object.keys(json).length;
        
        Core.Log.info(
            `Importing ${totalItems} items for ${collection._name}...` 
        );
          
        // loop over each item in json and insert into collection
        for (let item of json) {
          try {
            result = collection.insert(item);
          } catch (err) {
            Core.Log.error("Error adding initialisation data to " +
              collection._name + ":", err.message);
          }
        }

        if (result) {
          Core.Log.info(
            `Success importing initialisation data to ${collection._name} for tenant ${tenantId}`
          );
        }

      });  
    }
  }
/**
   * BootstrapLoader.loadPartitionData
   * @summary imports collection initialisation data for a specified tenant
   * @param {Object} collection - The collection to import
   * @param {String} group - The tenant to import data for, default to current Tenant if not provided
   * @param {String} jsonFile - path to json File.
   * @return {Boolean} boolean -  returns true on insert
   */
BootstrapLoader.loadPartitionData
@summary imports collection initialisation data for a specified tenant
@param {Object} collection - The collection to import
@param {String} group - The tenant to import data for, default to current Tenant if not provided
@param {String} jsonFile - path to json File.
@return {Boolean} boolean -  returns true on insert
BootstrapLoader . loadPartitionData @summary imports collection initialisation data for a specified tenant @param { Object } collection - The collection to import @param { String } group - The tenant to import data for default to current Tenant if not provided @param { String } jsonFile - path to json File . @return { Boolean } boolean - returns true on insert
loadPartitionData(collection, group, jsonFile) {
    check(collection, Mongo.Collection);
    check(group, Match.Optional(String));
    check(jsonFile, Match.Optional(String)); 
    let tenantId = group || Core.getDefaultTenantId();
    if (tenantId) {
      Partitioner.bindGroup(tenantId, function(){ 
        if (collection.find().count() > 0) {
          return false;
        }
        let json = null;
        let result = null;
        Core.Log.debug(
          `Loading initialisation data for ${collection._name} in tenant ${tenantId}`);
        if (!jsonFile) {
          json = EJSON.parse(Assets.getText("data/" + collection._name +
            ".json"));
        } else {
          json = EJSON.parse(jsonFile); 
        }
        let totalItems = Object.keys(json).length;
        Core.Log.info(
            `Importing ${totalItems} items for ${collection._name}...` 
        );
        for (let item of json) {
          try {
            result = collection.insert(item);
          } catch (err) {
            Core.Log.error("Error adding initialisation data to " +
              collection._name + ":", err.message);
          }
        }
        if (result) {
          Core.Log.info(
            `Success importing initialisation data to ${collection._name} for tenant ${tenantId}`
          );
        }
      });  
    }
  }
loadPartitionData ( collection , group , jsonFile ) { check ( collection , Mongo . Collection ) ; check ( group , Match . Optional ( String ) ) ; check ( jsonFile , Match . Optional ( String ) ) ; let tenantId = group || Core . getDefaultTenantId ( ) ; if ( tenantId ) { Partitioner . bindGroup ( tenantId , function ( ) { if ( collection . find ( ) . count ( ) > 0 ) { return false ; } let json = null ; let result = null ; Core . Log . debug ( ` ${ collection . _name } ${ tenantId } ` ) ; if ( ! jsonFile ) { json = EJSON . parse ( Assets . getText ( "data/" + collection . _name + ".json" ) ) ; } else { json = EJSON . parse ( jsonFile ) ; } let totalItems = Object . keys ( json ) . length ; Core . Log . info ( ` ${ totalItems } ${ collection . _name } ` ) ; for ( let item of json ) { try { result = collection . insert ( item ) ; } catch ( err ) { Core . Log . error ( "Error adding initialisation data to " + collection . _name + ":" , err . message ) ; } } if ( result ) { Core . Log . info ( ` ${ collection . _name } ${ tenantId } ` ) ; } } ) ; } }
BootstrapLoader.loadPartitionData
 @summary imports collection initialisation data for a specified tenant
 @param {Object} collection - The collection to import
 @param {String} group - The tenant to import data for, default to current Tenant if not provided
 @param {String} jsonFile - path to json File.
BootstrapLoader . loadPartitionData @summary imports collection initialisation data for a specified tenant @param { Object } collection - The collection to import @param { String } group - The tenant to import data for default to current Tenant if not provided @param { String } jsonFile - path to json File .
// prevent import if existing collection data for the partition // if jsonFile was path wasn't provided // we'll assume we're loading collection data // loop over each item in json and insert into collection