saveGlobalConfiguration = async (logger, configuration) => {
  // get old configuration before saving the new one to compare
  const oldConfiguration = await mongo.findOne(
    logger,
    'trailing-trade-common',
    {
      key: 'configuration'
    }
  );

  // Save to cache for watching changes.
  const result = await mongo.upsertOne(
    logger,
    'trailing-trade-common',
    {
      key: 'configuration'
    },
    {
      key: 'configuration',
      ...configuration
    }
  );

  await cache.hdelall('trailing-trade-configurations:*');

  await reconfigureIndex(logger, configuration);

  // reset all websockets only when symbols, candles or ath candles are changed
  if (
    _.isEqual(
      _.get(oldConfiguration, 'symbols', []),
      _.get(configuration, 'symbols', [])
    ) === false ||
    _.isEqual(
      _.get(oldConfiguration, 'candles', {}),
      _.get(configuration, 'candles', {})
    ) === false ||
    _.isEqual(
      _.get(oldConfiguration, ['buy', 'athRestriction', 'candles'], {}),
      _.get(configuration, ['buy', 'athRestriction', 'candles'], {})
    ) === false
  ) {
    PubSub.publish('reset-all-websockets', true);
  }

  return result;
}
Save global configuration to mongodb

@param {*} logger
@param {*} configuration