aboutsummaryrefslogtreecommitdiffstats
path: root/packages/shared/search.ts
diff options
context:
space:
mode:
authorMohamedBassem <me@mbassem.com>2024-03-30 16:26:16 +0000
committerMohamedBassem <me@mbassem.com>2024-03-30 16:26:16 +0000
commit46b78eaac30be26fe40520e97786563344af8403 (patch)
treec4c0e1ae1d3d21a6f1fbf5f44f68e99243bbb5d3 /packages/shared/search.ts
parent853ed13450b3a0d92cba144cc0dfd0696e7c810c (diff)
downloadkarakeep-46b78eaac30be26fe40520e97786563344af8403.tar.zst
format: Add missing lint and format, and format the entire repo
Diffstat (limited to 'packages/shared/search.ts')
-rw-r--r--packages/shared/search.ts32
1 files changed, 24 insertions, 8 deletions
diff --git a/packages/shared/search.ts b/packages/shared/search.ts
index 8422d79e..7cd81061 100644
--- a/packages/shared/search.ts
+++ b/packages/shared/search.ts
@@ -1,7 +1,9 @@
-import { MeiliSearch, Index } from "meilisearch";
-import serverConfig from "./config";
+import type { Index } from "meilisearch";
+import { MeiliSearch } from "meilisearch";
import { z } from "zod";
+import serverConfig from "./config";
+
export const zBookmarkIdxSchema = z.object({
id: z.string(),
userId: z.string(),
@@ -51,15 +53,29 @@ export async function getSearchIdxClient(): Promise<Index<ZBookmarkIdx> | null>
const desiredSortableAttributes = ["createdAt"].sort();
const settings = await idxFound.getSettings();
- if (JSON.stringify(settings.filterableAttributes?.sort()) != JSON.stringify(desiredFilterableAttributes)) {
- console.log(`[meilisearch] Updating desired filterable attributes to ${desiredFilterableAttributes} from ${settings.filterableAttributes}`);
- const taskId = await idxFound.updateFilterableAttributes(desiredFilterableAttributes);
+ if (
+ JSON.stringify(settings.filterableAttributes?.sort()) !=
+ JSON.stringify(desiredFilterableAttributes)
+ ) {
+ console.log(
+ `[meilisearch] Updating desired filterable attributes to ${desiredFilterableAttributes} from ${settings.filterableAttributes}`,
+ );
+ const taskId = await idxFound.updateFilterableAttributes(
+ desiredFilterableAttributes,
+ );
await searchClient.waitForTask(taskId.taskUid);
}
- if (JSON.stringify(settings.sortableAttributes?.sort()) != JSON.stringify(desiredSortableAttributes)) {
- console.log(`[meilisearch] Updating desired sortable attributes to ${desiredSortableAttributes} from ${settings.sortableAttributes}`);
- const taskId = await idxFound.updateSortableAttributes(desiredSortableAttributes);
+ if (
+ JSON.stringify(settings.sortableAttributes?.sort()) !=
+ JSON.stringify(desiredSortableAttributes)
+ ) {
+ console.log(
+ `[meilisearch] Updating desired sortable attributes to ${desiredSortableAttributes} from ${settings.sortableAttributes}`,
+ );
+ const taskId = await idxFound.updateSortableAttributes(
+ desiredSortableAttributes,
+ );
await searchClient.waitForTask(taskId.taskUid);
}
idxClient = idxFound;