diff --git a/packages/backend-core/src/constants/db.ts b/packages/backend-core/src/constants/db.ts index 19f493fd8e..d41098c405 100644 --- a/packages/backend-core/src/constants/db.ts +++ b/packages/backend-core/src/constants/db.ts @@ -24,11 +24,6 @@ export enum ViewName { APP_BACKUP_BY_TRIGGER = "by_trigger", } -export const SearchIndexes = { - ROWS: "rows", - AUDIT: "audit", -} - export const DeprecatedViews = { [ViewName.USER_BY_EMAIL]: [ // removed due to inaccuracy in view doc filter logic diff --git a/packages/server/src/api/controllers/row/internalSearch.ts b/packages/server/src/api/controllers/row/internalSearch.ts index bdb9379334..9dc12342d6 100644 --- a/packages/server/src/api/controllers/row/internalSearch.ts +++ b/packages/server/src/api/controllers/row/internalSearch.ts @@ -1,17 +1,12 @@ import { db as dbCore, context, SearchParams } from "@budibase/backend-core" -import { SearchFilters, Row } from "@budibase/types" +import { SearchFilters, Row, SearchIndex } from "@budibase/types" export async function paginatedSearch( query: SearchFilters, params: SearchParams ) { const appId = context.getAppId() - return dbCore.paginatedSearch( - appId!, - dbCore.SearchIndexes.ROWS, - query, - params - ) + return dbCore.paginatedSearch(appId!, SearchIndex.ROWS, query, params) } export async function fullSearch( @@ -19,5 +14,5 @@ export async function fullSearch( params: SearchParams ) { const appId = context.getAppId() - return dbCore.fullSearch(appId!, dbCore.SearchIndexes.ROWS, query, params) + return dbCore.fullSearch(appId!, SearchIndex.ROWS, query, params) } diff --git a/packages/server/src/db/views/staticViews.ts b/packages/server/src/db/views/staticViews.ts index 674dd20ec7..730e5b1e66 100644 --- a/packages/server/src/db/views/staticViews.ts +++ b/packages/server/src/db/views/staticViews.ts @@ -1,6 +1,6 @@ -import { context, db as dbCore } from "@budibase/backend-core" +import { context } from "@budibase/backend-core" import { DocumentType, SEPARATOR, ViewName } from "../utils" -import { LinkDocument, Row } from "@budibase/types" +import { LinkDocument, Row, SearchIndex } from "@budibase/types" const SCREEN_PREFIX = DocumentType.SCREEN + SEPARATOR /************************************************** @@ -91,7 +91,7 @@ async function searchIndex(indexName: string, fnString: string) { export async function createAllSearchIndex() { await searchIndex( - dbCore.SearchIndexes.ROWS, + SearchIndex.ROWS, function (doc: Row) { function idx(input: Row, prev?: string) { for (let key of Object.keys(input)) { diff --git a/packages/types/src/sdk/db.ts b/packages/types/src/sdk/db.ts index 092253d63a..6e213b5831 100644 --- a/packages/types/src/sdk/db.ts +++ b/packages/types/src/sdk/db.ts @@ -2,6 +2,11 @@ import Nano from "@budibase/nano" import { AllDocsResponse, AnyDocument, Document } from "../" import { Writable } from "stream" +export enum SearchIndex { + ROWS = "rows", + AUDIT = "audit", +} + export type PouchOptions = { inMemory?: boolean replication?: boolean