1
0
Fork 0
mirror of synced 2024-10-04 03:54:37 +13:00

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", APP_BACKUP_BY_TRIGGER = "by_trigger",
} }
export const SearchIndexes = {
ROWS: "rows",
AUDIT: "audit",
}
export const DeprecatedViews = { export const DeprecatedViews = {
[ViewName.USER_BY_EMAIL]: [ [ViewName.USER_BY_EMAIL]: [
// removed due to inaccuracy in view doc filter logic // 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 { 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( export async function paginatedSearch(
query: SearchFilters, query: SearchFilters,
params: SearchParams<Row> params: SearchParams<Row>
) { ) {
const appId = context.getAppId() const appId = context.getAppId()
return dbCore.paginatedSearch( return dbCore.paginatedSearch(appId!, SearchIndex.ROWS, query, params)
appId!,
dbCore.SearchIndexes.ROWS,
query,
params
)
} }
export async function fullSearch( export async function fullSearch(
@ -19,5 +14,5 @@ export async function fullSearch(
params: SearchParams<Row> params: SearchParams<Row>
) { ) {
const appId = context.getAppId() 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 { DocumentType, SEPARATOR, ViewName } from "../utils"
import { LinkDocument, Row } from "@budibase/types" import { LinkDocument, Row, SearchIndex } from "@budibase/types"
const SCREEN_PREFIX = DocumentType.SCREEN + SEPARATOR const SCREEN_PREFIX = DocumentType.SCREEN + SEPARATOR
/************************************************** /**************************************************
@ -91,7 +91,7 @@ async function searchIndex(indexName: string, fnString: string) {
export async function createAllSearchIndex() { export async function createAllSearchIndex() {
await searchIndex( await searchIndex(
dbCore.SearchIndexes.ROWS, SearchIndex.ROWS,
function (doc: Row) { function (doc: Row) {
function idx(input: Row, prev?: string) { function idx(input: Row, prev?: string) {
for (let key of Object.keys(input)) { for (let key of Object.keys(input)) {

View file

@ -2,6 +2,11 @@ import Nano from "@budibase/nano"
import { AllDocsResponse, AnyDocument, Document } from "../" import { AllDocsResponse, AnyDocument, Document } from "../"
import { Writable } from "stream" import { Writable } from "stream"
export enum SearchIndex {
ROWS = "rows",
AUDIT = "audit",
}
export type PouchOptions = { export type PouchOptions = {
inMemory?: boolean inMemory?: boolean
replication?: boolean replication?: boolean