From 5a802b6347a91393d4d6da89d4efd8b84edc1058 Mon Sep 17 00:00:00 2001 From: DrMint <29893320+DrMint@users.noreply.github.com> Date: Thu, 16 Feb 2023 08:39:33 +0100 Subject: [PATCH] Delete all indexes as part of initialization step --- src/syncho.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/syncho.ts b/src/syncho.ts index 5bf3211..d9b69ba 100644 --- a/src/syncho.ts +++ b/src/syncho.ts @@ -4,6 +4,10 @@ import { getMeili, strapiToMeiliTransformFunctions } from "helpers/meili"; export const synchronizeStrapiAndMeili = async (): Promise => { const sdk = getReadySdk(); + const meili = getMeili(); + const indexes = await meili.getIndexes(); + await Promise.all(indexes.results.map(async (index) => index.delete())); + // [ LIBRARY ITEMS ] @@ -88,7 +92,6 @@ const processIndex = async ( filterableAttributes?: (keyof NonNullable[number])[] ) => { const meili = getMeili(); - await meili.deleteIndexIfExists(indexName); if (data && data.length > 0) { await meili.createIndex(indexName);