lib/utils.js
function(fieldOrSpec) {
  var fieldHash = {};
  var indexes = [];
  var keys;

  // Get all the fields accordingly
  if ('string' === typeof fieldOrSpec) {
    // 'type'
    indexes.push(fieldOrSpec + '_' + 1);
    fieldHash[fieldOrSpec] = 1;
  } else if (Array.isArray(fieldOrSpec)) {
    fieldOrSpec.forEach(function(f) {
      if ('string' === typeof f) {
        // [{location:'2d'}, 'type']
        indexes.push(f + '_' + 1);
        fieldHash[f] = 1;
      } else if (Array.isArray(f)) {
        // [['location', '2d'],['type', 1]]
        indexes.push(f[0] + '_' + (f[1] || 1));
        fieldHash[f[0]] = f[1] || 1;
      } else if (isObject(f)) {
        // [{location:'2d'}, {type:1}]
        keys = Object.keys(f);
        keys.forEach(function(k) {
          indexes.push(k + '_' + f[k]);
          fieldHash[k] = f[k];
        });
      } else {
        // undefined (ignore)
      }
    });
  } else if (isObject(fieldOrSpec)) {
    // {location:'2d', type:1}
    keys = Object.keys(fieldOrSpec);
    keys.forEach(function(key) {
      indexes.push(key + '_' + fieldOrSpec[key]);
      fieldHash[key] = fieldOrSpec[key];
    });
  }

  return {
    name: indexes.join('_'),
    keys: keys,
    fieldHash: fieldHash
  };
}
function(fieldOrSpec) {
  var fieldHash = {};
  var indexes = [];
  var keys;

  // Get all the fields accordingly
  if ('string' === typeof fieldOrSpec) {
    // 'type'
    indexes.push(fieldOrSpec + '_' + 1);
    fieldHash[fieldOrSpec] = 1;
  } else if (Array.isArray(fieldOrSpec)) {
    fieldOrSpec.forEach(function(f) {
      if ('string' === typeof f) {
        // [{location:'2d'}, 'type']
        indexes.push(f + '_' + 1);
        fieldHash[f] = 1;
      } else if (Array.isArray(f)) {
        // [['location', '2d'],['type', 1]]
        indexes.push(f[0] + '_' + (f[1] || 1));
        fieldHash[f[0]] = f[1] || 1;
      } else if (isObject(f)) {
        // [{location:'2d'}, {type:1}]
        keys = Object.keys(f);
        keys.forEach(function(k) {
          indexes.push(k + '_' + f[k]);
          fieldHash[k] = f[k];
        });
      } else {
        // undefined (ignore)
      }
    });
  } else if (isObject(fieldOrSpec)) {
    // {location:'2d', type:1}
    keys = Object.keys(fieldOrSpec);
    keys.forEach(function(key) {
      indexes.push(key + '_' + fieldOrSpec[key]);
      fieldHash[key] = fieldOrSpec[key];
    });
  }

  return {
    name: indexes.join('_'),
    keys: keys,
    fieldHash: fieldHash
  };
}
function ( fieldOrSpec ) { var fieldHash = { } ; var indexes = [ ] ; var keys ; // Get all the fields accordingly if ( 'string' === typeof fieldOrSpec ) { // 'type' indexes . push ( fieldOrSpec + '_' + 1 ) ; fieldHash [ fieldOrSpec ] = 1 ; } else if ( Array . isArray ( fieldOrSpec ) ) { fieldOrSpec . forEach ( function ( f ) { if ( 'string' === typeof f ) { // [{location:'2d'}, 'type'] indexes . push ( f + '_' + 1 ) ; fieldHash [ f ] = 1 ; } else if ( Array . isArray ( f ) ) { // [['location', '2d'],['type', 1]] indexes . push ( f [ 0 ] + '_' + ( f [ 1 ] || 1 ) ) ; fieldHash [ f [ 0 ] ] = f [ 1 ] || 1 ; } else if ( isObject ( f ) ) { // [{location:'2d'}, {type:1}] keys = Object . keys ( f ) ; keys . forEach ( function ( k ) { indexes . push ( k + '_' + f [ k ] ) ; fieldHash [ k ] = f [ k ] ; } ) ; } else { // undefined (ignore) } } ) ; } else if ( isObject ( fieldOrSpec ) ) { // {location:'2d', type:1} keys = Object . keys ( fieldOrSpec ) ; keys . forEach ( function ( key ) { indexes . push ( key + '_' + fieldOrSpec [ key ] ) ; fieldHash [ key ] = fieldOrSpec [ key ] ; } ) ; } return { name : indexes . join ( '_' ) , keys : keys , fieldHash : fieldHash } ; }
Create index name based on field spec

@ignore
@api private
Create index name based on field spec