function prepareIndexKeys(node, resolvedFields, indexName, indexFields) {
  // TODO: use index id vs index name (shorter)
  const indexKeyElements = [];
  const multiKeyFields = [];
  indexKeyElements.push([indexName]);

  for (const dottedField of indexFields.keys()) {
    const fieldValue = (0, _common.resolveFieldValue)(dottedField, node, resolvedFields);
    let indexFieldValue = jsValueToLmdbKey(fieldValue); // Got value that can't be stored in lmdb key

    if (typeof indexFieldValue === `undefined`) {
      const path = `${node.internal.type}.${dottedField} (id: ${node.id})`;
      throw new Error(`Bad value at ${path}: ${(0, _util.inspect)(fieldValue)}`);
    }

    indexFieldValue = Array.isArray(indexFieldValue) ? indexFieldValue.flat() // FIXME
    : [indexFieldValue];
    indexKeyElements.push(indexFieldValue);

    if (indexFieldValue.length > 1) {
      multiKeyFields.push(dottedField);
    }
  }

  indexKeyElements.push([node.internal.counter]);
  return {
    keys: (0, _common.cartesianProduct)(...indexKeyElements),
    multiKeyFields
  };
}
/**
 * Returns a list of index keys for a given node.
 * One node may produce multiple index entries when indexing over array values.
 *
 * For example:
 *  Node: { foo: [{ bar: `bar1`}, { bar: `bar2` }] }
 *  Index fields: [`foo.bar`] will produce the following elements: [`bar1`, `bar2`]
 *
 * Keys are prefixed with index name and suffixed with node counter for stable sort.
 *
 * If materialization result (resolvedFields) exists for a given index field
 *  it is used as a key element, otherwise the a raw node value is used.
 */
Returns a list of index keys for a given node.
One node may produce multiple index entries when indexing over array values.



Keys are prefixed with index name and suffixed with node counter for stable sort.

If materialization result (resolvedFields) exists for a given index field
it is used as a key element, otherwise the a raw node value is used.
Returns a list of index keys for a given node . One node may produce multiple index entries when indexing over array values . Keys are prefixed with index name and suffixed with node counter for stable sort . If materialization result ( resolvedFields ) exists for a given index field it is used as a key element otherwise the a raw node value is used .
function prepareIndexKeys(node, resolvedFields, indexName, indexFields) {
  const indexKeyElements = [];
  const multiKeyFields = [];
  indexKeyElements.push([indexName]);
  for (const dottedField of indexFields.keys()) {
    const fieldValue = (0, _common.resolveFieldValue)(dottedField, node, resolvedFields);
    let indexFieldValue = jsValueToLmdbKey(fieldValue); 
    if (typeof indexFieldValue === `undefined`) {
      const path = `${node.internal.type}.${dottedField} (id: ${node.id})`;
      throw new Error(`Bad value at ${path}: ${(0, _util.inspect)(fieldValue)}`);
    }
    indexFieldValue = Array.isArray(indexFieldValue) ? indexFieldValue.flat() 
    : [indexFieldValue];
    indexKeyElements.push(indexFieldValue);
    if (indexFieldValue.length > 1) {
      multiKeyFields.push(dottedField);
    }
  }
  indexKeyElements.push([node.internal.counter]);
  return {
    keys: (0, _common.cartesianProduct)(...indexKeyElements),
    multiKeyFields
  };
}
function prepareIndexKeys ( node , resolvedFields , indexName , indexFields ) { const indexKeyElements = [ ] ; const multiKeyFields = [ ] ; indexKeyElements . push ( [ indexName ] ) ; for ( const dottedField of indexFields . keys ( ) ) { const fieldValue = ( 0 , _common . resolveFieldValue ) ( dottedField , node , resolvedFields ) ; let indexFieldValue = jsValueToLmdbKey ( fieldValue ) ; if ( typeof indexFieldValue === ` ` ) { const path = ` ${ node . internal . type } ${ dottedField } ${ node . id } ` ; throw new Error ( ` ${ path } ${ ( 0 , _util . inspect ) ( fieldValue ) } ` ) ; } indexFieldValue = Array . isArray ( indexFieldValue ) ? indexFieldValue . flat ( ) : [ indexFieldValue ] ; indexKeyElements . push ( indexFieldValue ) ; if ( indexFieldValue . length > 1 ) { multiKeyFields . push ( dottedField ) ; } } indexKeyElements . push ( [ node . internal . counter ] ) ; return { keys : ( 0 , _common . cartesianProduct ) ( ... indexKeyElements ) , multiKeyFields } ; }
Returns a list of index keys for a given node.
Returns a list of index keys for a given node .
// TODO: use index id vs index name (shorter) // Got value that can't be stored in lmdb key // FIXME