code: function buildIndexObjects (initialRefs, currentRefs) {
    const ret = []
    const refValueNames = Object.keys(initialRefs)
  
    refValueNames.forEach(refValueName => {
      const initialRefValue = initialRefs[refValueName]
      const currentRefValue = currentRefs[refValueName]
  
      if (!initialRefValue || !currentRefValue) {
        return
      }
  
      const name = initialRefValue.name
      const initialValue = initialRefValue.value
      const indexType = initialRefValue.indexType || currentRefs.indexType
      let currentValue = currentRefs[refValueName].value
  
      if (_.isNull(currentValue) || _.isUndefined(currentValue)) {
        currentValue = null
      }
  
      if (Array.isArray(currentValue)) {
        currentValue = currentValue.sort()
      }
  
      if (Array.isArray(initialValue) || Array.isArray(currentValue)) {
        const toRemove = _.difference(initialValue || [], currentValue || []) || []
        const union = _.union(initialValue || [], currentValue || []) || []
        const toAdd = _.difference(union, toRemove) || []
  
        toRemove.forEach(v => {
          ret.push({
            name,
            indexType,
            value: v,
            action: INDEX_ACTIONS.REMOVE
          })
        })
  
        toAdd.forEach(v => {
          ret.push({
            name,
            indexType,
            value: v,
            action: INDEX_ACTIONS.UPSERT
          })
        })
      } else if (_.isEqual(initialValue, currentValue)) {
        ret.push({
          name,
          value: currentValue,
          indexType,
          action: INDEX_ACTIONS.UPSERT
        })
      } else {
        if (initialValue !== null) {
          ret.push({
            name,
            value: initialValue,
            indexType,
            action: INDEX_ACTIONS.REMOVE
          })
        }
  
        if (currentValue !== null) {
          ret.push({
            name,
            value: currentValue,
            indexType,
            action: INDEX_ACTIONS.UPSERT
          })
        }
      }
    })
  
    return ret
  }
docs: /*!
  Builds index objects based on initial and current ref doc values
  @param initialRefs
  @param currentRefs
  @returns {Array}