feat(node) Remote drop table (#412)

This commit is contained in:
gsilvestrin
2023-08-10 09:21:36 -07:00
committed by GitHub
parent aa91f35a28
commit 03b8f99dca
2 changed files with 31 additions and 1 deletions

View File

@@ -104,4 +104,34 @@ export class HttpLancedbClient {
}
return response
}
/**
* Sent POST request.
*/
public async post (path: string, data?: any, params?: Record<string, string | number>): Promise<AxiosResponse> {
const response = await axios.post(
`${this._url}${path}`,
data,
{
headers: {
'Content-Type': 'application/json',
'x-api-key': this._apiKey(),
...(this._dbName !== undefined ? { 'x-lancedb-database': this._dbName } : {})
},
params,
timeout: 30000
}
).catch((err) => {
console.error('error: ', err)
return err.response
})
if (response.status !== 200) {
const errorData = new TextDecoder().decode(response.data)
throw new Error(
`Server Error, status: ${response.status as number}, ` +
`message: ${response.statusText as string}: ${errorData}`
)
}
return response
}
}

View File

@@ -77,7 +77,7 @@ export class RemoteConnection implements Connection {
}
async dropTable (name: string): Promise<void> {
throw new Error('Not implemented')
await this._client.post(`/v1/table/${name}/drop/`)
}
}