How to use the @algolia/client-search.exists function in @algolia/client-search

To help you get started, we’ve selected a few @algolia/client-search examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github algolia / algoliasearch-client-javascript / packages / client-account / src / methods / accountCopyIndex.ts View on Github external
export const accountCopyIndex = (
  source: SearchIndex,
  destination: SearchIndex,
  requestOptions: RequestOptions
): WaitablePromise => {
  // eslint-disable-next-line functional/prefer-readonly-type
  const responses: Array> = [];

  const promise = exists(destination)()
    .then(res => {
      if (source.appId === destination.appId) {
        throw createIndicesInSameAppError(source.appId);
      }

      if (res) {
        throw createDestinationIndiceExistsError();
      }
    })
    .then(() => getSettings(source)())
    .then(settings =>
      // eslint-disable-next-line functional/immutable-data
      responses.push(setSettings(destination)(settings, requestOptions))
    )
    .then(() =>
      browseRules(source)({