Files
lancedb/docs/src/javascript/interfaces/Table.md
Will Jones ee0f0611d9 docs: update node API reference (#734)
This command hasn't been run for a while...
2023-12-22 10:14:31 -08:00

6.4 KiB

vectordb / Exports / Table

Interface: Table<T>

A LanceDB Table is the collection of Records. Each Record has one or more vector fields.

Type parameters

Name Type
T number[]

Implemented by

Table of contents

Properties

Properties

add

add: (data: Record<string, unknown>[]) => Promise<number>

Type declaration

▸ (data): Promise<number>

Insert records into this Table.

Parameters
Name Type Description
data Record<string, unknown>[] Records to be inserted into the Table
Returns

Promise<number>

The number of rows added to the table

Defined in

index.ts:209


countRows

countRows: () => Promise<number>

Type declaration

▸ (): Promise<number>

Returns the number of rows in this table.

Returns

Promise<number>

Defined in

index.ts:229


createIndex

createIndex: (indexParams: IvfPQIndexConfig) => Promise<any>

Type declaration

▸ (indexParams): Promise<any>

Create an ANN index on this Table vector index.

Parameters
Name Type Description
indexParams IvfPQIndexConfig The parameters of this Index,
Returns

Promise<any>

See

VectorIndexParams.

Defined in

index.ts:224


delete

delete: (filter: string) => Promise<void>

Type declaration

▸ (filter): Promise<void>

Delete rows from this table.

This can be used to delete a single row, many rows, all rows, or sometimes no rows (if your predicate matches nothing).

Parameters
Name Type Description
filter string A filter in the same format used by a sql WHERE clause. The filter must not be empty.
Returns

Promise<void>

Examples

const con = await lancedb.connect("./.lancedb")
const data = [
   {id: 1, vector: [1, 2]},
   {id: 2, vector: [3, 4]},
   {id: 3, vector: [5, 6]},
];
const tbl = await con.createTable("my_table", data)
await tbl.delete("id = 2")
await tbl.countRows() // Returns 2

If you have a list of values to delete, you can combine them into a stringified list and use the IN operator:

const to_remove = [1, 5];
await tbl.delete(`id IN (${to_remove.join(",")})`)
await tbl.countRows() // Returns 1

Defined in

index.ts:263


indexStats

indexStats: (indexUuid: string) => Promise<IndexStats>

Type declaration

▸ (indexUuid): Promise<IndexStats>

Get statistics about an index.

Parameters
Name Type
indexUuid string
Returns

Promise<IndexStats>

Defined in

index.ts:306


listIndices

listIndices: () => Promise<VectorIndex[]>

Type declaration

▸ (): Promise<VectorIndex[]>

List the indicies on this table.

Returns

Promise<VectorIndex[]>

Defined in

index.ts:301


name

name: string

Defined in

index.ts:195


overwrite

overwrite: (data: Record<string, unknown>[]) => Promise<number>

Type declaration

▸ (data): Promise<number>

Insert records into this Table, replacing its contents.

Parameters
Name Type Description
data Record<string, unknown>[] Records to be inserted into the Table
Returns

Promise<number>

The number of rows added to the table

Defined in

index.ts:217


search: (query: T) => Query<T>

Type declaration

▸ (query): Query<T>

Creates a search query to find the nearest neighbors of the given search term

Parameters
Name Type Description
query T The query search term
Returns

Query<T>

Defined in

index.ts:201


update

update: (args: UpdateArgs | UpdateSqlArgs) => Promise<void>

Type declaration

▸ (args): Promise<void>

Update rows in this table.

This can be used to update a single row, many rows, all rows, or sometimes no rows (if your predicate matches nothing).

Parameters
Name Type Description
args UpdateArgs | UpdateSqlArgs see UpdateArgs and UpdateSqlArgs for more details
Returns

Promise<void>

Examples

const con = await lancedb.connect("./.lancedb")
const data = [
   {id: 1, vector: [3, 3], name: 'Ye'},
   {id: 2, vector: [4, 4], name: 'Mike'},
];
const tbl = await con.createTable("my_table", data)

await tbl.update({
  filter: "id = 2",
  updates: { vector: [2, 2], name: "Michael" },
})

let results = await tbl.search([1, 1]).execute();
// Returns [
//   {id: 2, vector: [2, 2], name: 'Michael'}
//   {id: 1, vector: [3, 3], name: 'Ye'}
// ]

Defined in

index.ts:296