fix(node) Unit tests hangs and don't exit (#396)

This commit is contained in:
gsilvestrin
2023-08-04 20:18:23 -07:00
committed by GitHub
parent bbfadfe58d
commit b69b1e3ec8
5 changed files with 41 additions and 3 deletions

View File

@@ -23,7 +23,7 @@ import { Query } from './query'
import { isEmbeddingFunction } from './embedding/embedding_function'
// eslint-disable-next-line @typescript-eslint/no-var-requires
const { databaseNew, databaseTableNames, databaseOpenTable, databaseDropTable, tableCreate, tableAdd, tableCreateVectorIndex, tableCountRows, tableDelete } = require('../native.js')
const { databaseNew, databaseTableNames, databaseOpenTable, databaseDropTable, tableCreate, tableAdd, tableCreateVectorIndex, tableCountRows, tableDelete, tableClose } = require('../native.js')
export { Query }
export type { EmbeddingFunction }
@@ -215,6 +215,12 @@ export interface Table<T = number[]> {
* ```
*/
delete: (filter: string) => Promise<void>
/**
* Immediately closes the connection to this Table. After close is called,
* all operations on this Table will fail.
*/
close: () => Promise<void>
}
/**
@@ -402,6 +408,14 @@ export class LocalTable<T = number[]> implements Table<T> {
async delete (filter: string): Promise<void> {
return tableDelete.call(this._tbl, filter)
}
/**
* Immediately closes the connection to this Table. After close is called,
* all operations on this Table will fail.
*/
async close (): Promise<void> {
return tableClose.call(this._tbl)
}
}
/// Config to build IVF_PQ index.

View File

@@ -165,4 +165,8 @@ export class RemoteTable<T = number[]> implements Table<T> {
async delete (filter: string): Promise<void> {
throw new Error('Not implemented')
}
async close (): Promise<void> {
throw new Error('Not implemented')
}
}