Fixing an issue with typing + wrong parameter being passed to the direct Couch call functionality.

This commit is contained in:
mike12345567 2024-05-03 18:00:43 +01:00
parent b457bee2fc
commit 070659c7b1
2 changed files with 6 additions and 4 deletions

View File

@ -21,6 +21,7 @@ import { WriteStream, ReadStream } from "fs"
import { newid } from "../../docIds/newid"
import { SQLITE_DESIGN_DOC_ID } from "../../constants"
import { DDInstrumentedDatabase } from "../instrumentation"
import { checkSlashesInUrl } from "../../helpers"
const DATABASE_NOT_FOUND = "Database does not exist."
@ -252,17 +253,18 @@ export class DatabaseImpl implements Database {
async _sqlQuery<T>(
url: string,
method: "POST" | "GET",
body?: any
body?: Record<string, any>
): Promise<T> {
url = checkSlashesInUrl(`${this.couchInfo.sqlUrl}/${url}`)
const args: { url: string; method: string; cookie: string; body?: any } = {
url: `${this.couchInfo.sqlUrl}/${url}`,
url,
method,
cookie: this.couchInfo.cookie,
}
if (body) {
args.body = body
}
const response = await directCouchUrlCall(body)
const response = await directCouchUrlCall(args)
if (response.status > 300) {
throw new Error(await response.text())
}

View File

@ -21,7 +21,7 @@ export async function directCouchUrlCall({
url: string
cookie: string
method: string
body?: any
body?: Record<string, any>
}) {
const params: any = {
method: method,