Delete all indexes as part of initialization step

This commit is contained in:
DrMint 2023-02-16 08:39:33 +01:00
parent ec09459441
commit 5a802b6347
1 changed files with 4 additions and 1 deletions

View File

@ -4,6 +4,10 @@ import { getMeili, strapiToMeiliTransformFunctions } from "helpers/meili";
export const synchronizeStrapiAndMeili = async (): Promise<void> => {
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 <I extends MeiliDocumentsType["index"]>(
filterableAttributes?: (keyof NonNullable<typeof data>[number])[]
) => {
const meili = getMeili();
await meili.deleteIndexIfExists(indexName);
if (data && data.length > 0) {
await meili.createIndex(indexName);