Moving search index to an enum.

This commit is contained in:
mike12345567 2023-02-24 13:15:14 +00:00
parent 42fc004212
commit f070be5f65
4 changed files with 11 additions and 16 deletions

View File

@ -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

View File

@ -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<Row>
) {
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<Row>
) {
const appId = context.getAppId()
return dbCore.fullSearch(appId!, dbCore.SearchIndexes.ROWS, query, params)
return dbCore.fullSearch(appId!, SearchIndex.ROWS, query, params)
}

View File

@ -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)) {

View File

@ -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