Require params on db.remove

This commit is contained in:
Rory Powell 2022-11-21 10:07:51 +00:00
parent cc3b174f87
commit e6589fd4c1
2 changed files with 5 additions and 5 deletions

View File

@ -2,7 +2,7 @@ import { updateLinks, EventType } from "../../../db/linkedRows"
import { getRowParams, generateTableID } from "../../../db/utils"
import { FieldTypes } from "../../../constants"
import { TableSaveFunctions, hasTypeChanged, handleDataImport } from "./utils"
const { getAppDB } = require("@budibase/backend-core/context")
import { context } from "@budibase/backend-core"
import { isTest } from "../../../environment"
import {
cleanupAttachments,
@ -35,7 +35,7 @@ function checkAutoColumns(table: Table, oldTable: Table) {
}
export async function save(ctx: any) {
const db = getAppDB()
const db = context.getAppDB()
const { dataImport, ...rest } = ctx.request.body
let tableToSave = {
type: "table",
@ -138,7 +138,7 @@ export async function save(ctx: any) {
}
export async function destroy(ctx: any) {
const db = getAppDB()
const db = context.getAppDB()
const tableToDelete = await db.get(ctx.params.tableId)
// Delete all rows for that table
@ -161,7 +161,7 @@ export async function destroy(ctx: any) {
})
// don't remove the table itself until very end
await db.remove(tableToDelete)
await db.remove(tableToDelete._id, tableToDelete._rev)
// remove table search index
if (!isTest() || env.COUCH_DB_URL) {

View File

@ -50,7 +50,7 @@ export interface Database {
exists(): Promise<boolean>
checkSetup(): Promise<Nano.DocumentScope<any>>
get<T>(id?: string): Promise<T | any>
remove(id?: string, rev?: string): Promise<Nano.DocumentDestroyResponse>
remove(id: string, rev: string): Promise<Nano.DocumentDestroyResponse>
put(
document: AnyDocument,
opts?: DatabasePutOpts