@lancedb/lancedb 0.4.16 → 0.4.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,19 @@
1
- import { Connection as LanceDbConnection } from "./native";
1
+ import { ConnectionOptions, Connection as LanceDbConnection } from "./native";
2
2
  import { Table } from "./table";
3
3
  import { Table as ArrowTable, Schema } from "apache-arrow";
4
+ /**
5
+ * Connect to a LanceDB instance at the given URI.
6
+ *
7
+ * Accepted formats:
8
+ *
9
+ * - `/path/to/database` - local database
10
+ * - `s3://bucket/path/to/database` or `gs://bucket/path/to/database` - database on cloud storage
11
+ * - `db://host:port` - remote database (LanceDB cloud)
12
+ * @param {string} uri - The uri of the database. If the database uri starts
13
+ * with `db://` then it connects to a remote database.
14
+ * @see {@link ConnectionOptions} for more details on the URI format.
15
+ */
16
+ export declare function connect(uri: string, opts?: Partial<ConnectionOptions>): Promise<Connection>;
4
17
  export interface CreateTableOptions {
5
18
  /**
6
19
  * The mode to use when creating the table.
@@ -17,6 +30,38 @@ export interface CreateTableOptions {
17
30
  * then no error will be raised.
18
31
  */
19
32
  existOk: boolean;
33
+ /**
34
+ * Configuration for object storage.
35
+ *
36
+ * Options already set on the connection will be inherited by the table,
37
+ * but can be overridden here.
38
+ *
39
+ * The available options are described at https://lancedb.github.io/lancedb/guides/storage/
40
+ */
41
+ storageOptions?: Record<string, string>;
42
+ }
43
+ export interface OpenTableOptions {
44
+ /**
45
+ * Configuration for object storage.
46
+ *
47
+ * Options already set on the connection will be inherited by the table,
48
+ * but can be overridden here.
49
+ *
50
+ * The available options are described at https://lancedb.github.io/lancedb/guides/storage/
51
+ */
52
+ storageOptions?: Record<string, string>;
53
+ /**
54
+ * Set the size of the index cache, specified as a number of entries
55
+ *
56
+ * The exact meaning of an "entry" will depend on the type of index:
57
+ * - IVF: there is one entry for each IVF partition
58
+ * - BTREE: there is one entry for the entire index
59
+ *
60
+ * This cache applies to the entire opened table, across all indices.
61
+ * Setting this value higher will increase performance on larger datasets
62
+ * at the expense of more RAM
63
+ */
64
+ indexCacheSize?: number;
20
65
  }
21
66
  export interface TableNamesOptions {
22
67
  /**
@@ -75,7 +120,7 @@ export declare class Connection {
75
120
  * Open a table in the database.
76
121
  * @param {string} name - The name of the table
77
122
  */
78
- openTable(name: string): Promise<Table>;
123
+ openTable(name: string, options?: Partial<OpenTableOptions>): Promise<Table>;
79
124
  /**
80
125
  * Creates a new Table and initialize it with new data.
81
126
  * @param {string} name - The name of the table.
@@ -13,10 +13,30 @@
13
13
  // See the License for the specific language governing permissions and
14
14
  // limitations under the License.
15
15
  Object.defineProperty(exports, "__esModule", { value: true });
16
- exports.Connection = void 0;
16
+ exports.Connection = exports.connect = void 0;
17
17
  const arrow_1 = require("./arrow");
18
+ const native_1 = require("./native");
18
19
  const table_1 = require("./table");
19
20
  const apache_arrow_1 = require("apache-arrow");
21
+ /**
22
+ * Connect to a LanceDB instance at the given URI.
23
+ *
24
+ * Accepted formats:
25
+ *
26
+ * - `/path/to/database` - local database
27
+ * - `s3://bucket/path/to/database` or `gs://bucket/path/to/database` - database on cloud storage
28
+ * - `db://host:port` - remote database (LanceDB cloud)
29
+ * @param {string} uri - The uri of the database. If the database uri starts
30
+ * with `db://` then it connects to a remote database.
31
+ * @see {@link ConnectionOptions} for more details on the URI format.
32
+ */
33
+ async function connect(uri, opts) {
34
+ opts = opts ?? {};
35
+ opts.storageOptions = cleanseStorageOptions(opts.storageOptions);
36
+ const nativeConn = await native_1.Connection.new(uri, opts);
37
+ return new Connection(nativeConn);
38
+ }
39
+ exports.connect = connect;
20
40
  /**
21
41
  * A LanceDB Connection that allows you to open tables and create new ones.
22
42
  *
@@ -72,8 +92,8 @@ class Connection {
72
92
  * Open a table in the database.
73
93
  * @param {string} name - The name of the table
74
94
  */
75
- async openTable(name) {
76
- const innerTable = await this.inner.openTable(name);
95
+ async openTable(name, options) {
96
+ const innerTable = await this.inner.openTable(name, cleanseStorageOptions(options?.storageOptions), options?.indexCacheSize);
77
97
  return new table_1.Table(innerTable);
78
98
  }
79
99
  /**
@@ -96,7 +116,7 @@ class Connection {
96
116
  table = (0, arrow_1.makeArrowTable)(data);
97
117
  }
98
118
  const buf = await (0, arrow_1.fromTableToBuffer)(table);
99
- const innerTable = await this.inner.createTable(name, buf, mode);
119
+ const innerTable = await this.inner.createTable(name, buf, mode, cleanseStorageOptions(options?.storageOptions));
100
120
  return new table_1.Table(innerTable);
101
121
  }
102
122
  /**
@@ -112,7 +132,7 @@ class Connection {
112
132
  }
113
133
  const table = (0, arrow_1.makeEmptyTable)(schema);
114
134
  const buf = await (0, arrow_1.fromTableToBuffer)(table);
115
- const innerTable = await this.inner.createEmptyTable(name, buf, mode);
135
+ const innerTable = await this.inner.createEmptyTable(name, buf, mode, cleanseStorageOptions(options?.storageOptions));
116
136
  return new table_1.Table(innerTable);
117
137
  }
118
138
  /**
@@ -124,3 +144,38 @@ class Connection {
124
144
  }
125
145
  }
126
146
  exports.Connection = Connection;
147
+ /**
148
+ * Takes storage options and makes all the keys snake case.
149
+ */
150
+ function cleanseStorageOptions(options) {
151
+ if (options === undefined) {
152
+ return undefined;
153
+ }
154
+ const result = {};
155
+ for (const [key, value] of Object.entries(options)) {
156
+ if (value !== undefined) {
157
+ const newKey = camelToSnakeCase(key);
158
+ result[newKey] = value;
159
+ }
160
+ }
161
+ return result;
162
+ }
163
+ /**
164
+ * Convert a string to snake case. It might already be snake case, in which case it is
165
+ * returned unchanged.
166
+ */
167
+ function camelToSnakeCase(camel) {
168
+ if (camel.includes("_")) {
169
+ // Assume if there is at least one underscore, it is already snake case
170
+ return camel;
171
+ }
172
+ if (camel.toLocaleUpperCase() === camel) {
173
+ // Assume if the string is all uppercase, it is already snake case
174
+ return camel;
175
+ }
176
+ let result = camel.replace(/[A-Z]/g, (letter) => `_${letter.toLowerCase()}`);
177
+ if (result.startsWith("_")) {
178
+ result = result.slice(1);
179
+ }
180
+ return result;
181
+ }
package/dist/index.d.ts CHANGED
@@ -1,22 +1,7 @@
1
- import { Connection } from "./connection";
2
- import { ConnectionOptions } from "./native.js";
3
1
  export { WriteOptions, WriteMode, AddColumnsSql, ColumnAlteration, ConnectionOptions, } from "./native.js";
4
2
  export { makeArrowTable, MakeArrowTableOptions, Data, VectorColumnOptions, } from "./arrow";
5
- export { Connection, CreateTableOptions, TableNamesOptions, } from "./connection";
3
+ export { connect, Connection, CreateTableOptions, TableNamesOptions, } from "./connection";
6
4
  export { ExecutableQuery, Query, QueryBase, VectorQuery, RecordBatchIterator, } from "./query";
7
5
  export { Index, IndexOptions, IvfPqOptions } from "./indices";
8
6
  export { Table, AddDataOptions, IndexConfig, UpdateOptions } from "./table";
9
7
  export * as embedding from "./embedding";
10
- /**
11
- * Connect to a LanceDB instance at the given URI.
12
- *
13
- * Accpeted formats:
14
- *
15
- * - `/path/to/database` - local database
16
- * - `s3://bucket/path/to/database` or `gs://bucket/path/to/database` - database on cloud storage
17
- * - `db://host:port` - remote database (LanceDB cloud)
18
- * @param {string} uri - The uri of the database. If the database uri starts
19
- * with `db://` then it connects to a remote database.
20
- * @see {@link ConnectionOptions} for more details on the URI format.
21
- */
22
- export declare function connect(uri: string, opts?: Partial<ConnectionOptions>): Promise<Connection>;
package/dist/index.js CHANGED
@@ -13,15 +13,14 @@
13
13
  // See the License for the specific language governing permissions and
14
14
  // limitations under the License.
15
15
  Object.defineProperty(exports, "__esModule", { value: true });
16
- exports.connect = exports.embedding = exports.Table = exports.Index = exports.RecordBatchIterator = exports.VectorQuery = exports.QueryBase = exports.Query = exports.Connection = exports.VectorColumnOptions = exports.MakeArrowTableOptions = exports.makeArrowTable = void 0;
17
- const connection_1 = require("./connection");
18
- const native_js_1 = require("./native.js");
16
+ exports.embedding = exports.Table = exports.Index = exports.RecordBatchIterator = exports.VectorQuery = exports.QueryBase = exports.Query = exports.Connection = exports.connect = exports.VectorColumnOptions = exports.MakeArrowTableOptions = exports.makeArrowTable = void 0;
19
17
  var arrow_1 = require("./arrow");
20
18
  Object.defineProperty(exports, "makeArrowTable", { enumerable: true, get: function () { return arrow_1.makeArrowTable; } });
21
19
  Object.defineProperty(exports, "MakeArrowTableOptions", { enumerable: true, get: function () { return arrow_1.MakeArrowTableOptions; } });
22
20
  Object.defineProperty(exports, "VectorColumnOptions", { enumerable: true, get: function () { return arrow_1.VectorColumnOptions; } });
23
- var connection_2 = require("./connection");
24
- Object.defineProperty(exports, "Connection", { enumerable: true, get: function () { return connection_2.Connection; } });
21
+ var connection_1 = require("./connection");
22
+ Object.defineProperty(exports, "connect", { enumerable: true, get: function () { return connection_1.connect; } });
23
+ Object.defineProperty(exports, "Connection", { enumerable: true, get: function () { return connection_1.Connection; } });
25
24
  var query_1 = require("./query");
26
25
  Object.defineProperty(exports, "Query", { enumerable: true, get: function () { return query_1.Query; } });
27
26
  Object.defineProperty(exports, "QueryBase", { enumerable: true, get: function () { return query_1.QueryBase; } });
@@ -32,21 +31,3 @@ Object.defineProperty(exports, "Index", { enumerable: true, get: function () { r
32
31
  var table_1 = require("./table");
33
32
  Object.defineProperty(exports, "Table", { enumerable: true, get: function () { return table_1.Table; } });
34
33
  exports.embedding = require("./embedding");
35
- /**
36
- * Connect to a LanceDB instance at the given URI.
37
- *
38
- * Accpeted formats:
39
- *
40
- * - `/path/to/database` - local database
41
- * - `s3://bucket/path/to/database` or `gs://bucket/path/to/database` - database on cloud storage
42
- * - `db://host:port` - remote database (LanceDB cloud)
43
- * @param {string} uri - The uri of the database. If the database uri starts
44
- * with `db://` then it connects to a remote database.
45
- * @see {@link ConnectionOptions} for more details on the URI format.
46
- */
47
- async function connect(uri, opts) {
48
- opts = opts ?? {};
49
- const nativeConn = await native_js_1.Connection.new(uri, opts);
50
- return new connection_1.Connection(nativeConn);
51
- }
52
- exports.connect = connect;
package/dist/native.d.ts CHANGED
@@ -62,6 +62,12 @@ export interface ConnectionOptions {
62
62
  * always consistent.
63
63
  */
64
64
  readConsistencyInterval?: number
65
+ /**
66
+ * (For LanceDB OSS only): configuration for object storage.
67
+ *
68
+ * The available options are described at https://lancedb.github.io/lancedb/guides/storage/
69
+ */
70
+ storageOptions?: Record<string, string>
65
71
  }
66
72
  /** Write mode for writing a table. */
67
73
  export const enum WriteMode {
@@ -73,7 +79,9 @@ export const enum WriteMode {
73
79
  export interface WriteOptions {
74
80
  mode?: WriteMode
75
81
  }
76
- export function connect(uri: string, options: ConnectionOptions): Promise<Connection>
82
+ export interface OpenTableOptions {
83
+ storageOptions?: Record<string, string>
84
+ }
77
85
  export class Connection {
78
86
  /** Create a new Connection instance from the given URI. */
79
87
  static new(uri: string, options: ConnectionOptions): Promise<Connection>
@@ -90,9 +98,9 @@ export class Connection {
90
98
  * - buf: The buffer containing the IPC file.
91
99
  *
92
100
  */
93
- createTable(name: string, buf: Buffer, mode: string): Promise<Table>
94
- createEmptyTable(name: string, schemaBuf: Buffer, mode: string): Promise<Table>
95
- openTable(name: string): Promise<Table>
101
+ createTable(name: string, buf: Buffer, mode: string, storageOptions?: Record<string, string> | undefined | null): Promise<Table>
102
+ createEmptyTable(name: string, schemaBuf: Buffer, mode: string, storageOptions?: Record<string, string> | undefined | null): Promise<Table>
103
+ openTable(name: string, storageOptions?: Record<string, string> | undefined | null, indexCacheSize?: number | undefined | null): Promise<Table>
96
104
  /** Drop table with the name. Or raise an error if the table does not exist. */
97
105
  dropTable(name: string): Promise<void>
98
106
  }
package/dist/native.js CHANGED
@@ -303,7 +303,7 @@ if (!nativeBinding) {
303
303
  }
304
304
  throw new Error(`Failed to load native binding`);
305
305
  }
306
- const { Connection, Index, RecordBatchIterator, Query, VectorQuery, Table, WriteMode, connect } = nativeBinding;
306
+ const { Connection, Index, RecordBatchIterator, Query, VectorQuery, Table, WriteMode } = nativeBinding;
307
307
  module.exports.Connection = Connection;
308
308
  module.exports.Index = Index;
309
309
  module.exports.RecordBatchIterator = RecordBatchIterator;
@@ -311,4 +311,3 @@ module.exports.Query = Query;
311
311
  module.exports.VectorQuery = VectorQuery;
312
312
  module.exports.Table = Table;
313
313
  module.exports.WriteMode = WriteMode;
314
- module.exports.connect = connect;
package/dist/table.d.ts CHANGED
@@ -104,17 +104,20 @@ export declare class Table {
104
104
  * // If the column has a vector (fixed size list) data type then
105
105
  * // an IvfPq vector index will be created.
106
106
  * const table = await conn.openTable("my_table");
107
- * await table.createIndex(["vector"]);
107
+ * await table.createIndex("vector");
108
108
  * @example
109
109
  * // For advanced control over vector index creation you can specify
110
110
  * // the index type and options.
111
111
  * const table = await conn.openTable("my_table");
112
- * await table.createIndex(["vector"], I)
113
- * .ivf_pq({ num_partitions: 128, num_sub_vectors: 16 })
114
- * .build();
112
+ * await table.createIndex("vector", {
113
+ * config: lancedb.Index.ivfPq({
114
+ * numPartitions: 128,
115
+ * numSubVectors: 16,
116
+ * }),
117
+ * });
115
118
  * @example
116
119
  * // Or create a Scalar index
117
- * await table.createIndex("my_float_col").build();
120
+ * await table.createIndex("my_float_col");
118
121
  */
119
122
  createIndex(column: string, options?: Partial<IndexOptions>): Promise<void>;
120
123
  /**
@@ -126,8 +129,7 @@ export declare class Table {
126
129
  * vector similarity, sorting, and more.
127
130
  *
128
131
  * Note: By default, all columns are returned. For best performance, you should
129
- * only fetch the columns you need. See [`Query::select_with_projection`] for
130
- * more details.
132
+ * only fetch the columns you need.
131
133
  *
132
134
  * When appropriate, various indices and statistics based pruning will be used to
133
135
  * accelerate the query.
@@ -135,10 +137,13 @@ export declare class Table {
135
137
  * // SQL-style filtering
136
138
  * //
137
139
  * // This query will return up to 1000 rows whose value in the `id` column
138
- * // is greater than 5. LanceDb supports a broad set of filtering functions.
139
- * for await (const batch of table.query()
140
- * .filter("id > 1").select(["id"]).limit(20)) {
141
- * console.log(batch);
140
+ * // is greater than 5. LanceDb supports a broad set of filtering functions.
141
+ * for await (const batch of table
142
+ * .query()
143
+ * .where("id > 1")
144
+ * .select(["id"])
145
+ * .limit(20)) {
146
+ * console.log(batch);
142
147
  * }
143
148
  * @example
144
149
  * // Vector Similarity Search
@@ -147,13 +152,14 @@ export declare class Table {
147
152
  * // closest to the query vector [1.0, 2.0, 3.0]. If an index has been created
148
153
  * // on the "vector" column then this will perform an ANN search.
149
154
  * //
150
- * // The `refine_factor` and `nprobes` methods are used to control the recall /
155
+ * // The `refineFactor` and `nprobes` methods are used to control the recall /
151
156
  * // latency tradeoff of the search.
152
- * for await (const batch of table.query()
153
- * .nearestTo([1, 2, 3])
154
- * .refineFactor(5).nprobe(10)
155
- * .limit(10)) {
156
- * console.log(batch);
157
+ * for await (const batch of table
158
+ * .query()
159
+ * .where("id > 1")
160
+ * .select(["id"])
161
+ * .limit(20)) {
162
+ * console.log(batch);
157
163
  * }
158
164
  * @example
159
165
  * // Scan the full dataset
@@ -199,37 +205,39 @@ export declare class Table {
199
205
  * (e.g. "a").
200
206
  */
201
207
  dropColumns(columnNames: string[]): Promise<void>;
202
- /**
203
- * Retrieve the version of the table
204
- *
205
- * LanceDb supports versioning. Every operation that modifies the table increases
206
- * version. As long as a version hasn't been deleted you can `[Self::checkout]` that
207
- * version to view the data at that point. In addition, you can `[Self::restore]` the
208
- * version to replace the current table with a previous version.
209
- */
208
+ /** Retrieve the version of the table */
210
209
  version(): Promise<number>;
211
210
  /**
212
- * Checks out a specific version of the Table
211
+ * Checks out a specific version of the table _This is an in-place operation._
213
212
  *
214
- * Any read operation on the table will now access the data at the checked out version.
215
- * As a consequence, calling this method will disable any read consistency interval
216
- * that was previously set.
213
+ * This allows viewing previous versions of the table. If you wish to
214
+ * keep writing to the dataset starting from an old version, then use
215
+ * the `restore` function.
217
216
  *
218
- * This is a read-only operation that turns the table into a sort of "view"
219
- * or "detached head". Other table instances will not be affected. To make the change
220
- * permanent you can use the `[Self::restore]` method.
221
- *
222
- * Any operation that modifies the table will fail while the table is in a checked
223
- * out state.
217
+ * Calling this method will set the table into time-travel mode. If you
218
+ * wish to return to standard mode, call `checkoutLatest`.
219
+ * @param {number} version The version to checkout
220
+ * @example
221
+ * ```typescript
222
+ * import * as lancedb from "@lancedb/lancedb"
223
+ * const db = await lancedb.connect("./.lancedb");
224
+ * const table = await db.createTable("my_table", [
225
+ * { vector: [1.1, 0.9], type: "vector" },
226
+ * ]);
224
227
  *
225
- * To return the table to a normal state use `[Self::checkout_latest]`
228
+ * console.log(await table.version()); // 1
229
+ * console.log(table.display());
230
+ * await table.add([{ vector: [0.5, 0.2], type: "vector" }]);
231
+ * await table.checkout(1);
232
+ * console.log(await table.version()); // 2
233
+ * ```
226
234
  */
227
235
  checkout(version: number): Promise<void>;
228
236
  /**
229
- * Ensures the table is pointing at the latest version
237
+ * Checkout the latest version of the table. _This is an in-place operation._
230
238
  *
231
- * This can be used to manually update a table when the read_consistency_interval is None
232
- * It can also be used to undo a `[Self::checkout]` operation
239
+ * The table will be set back into standard mode, and will track the latest
240
+ * version of the table.
233
241
  */
234
242
  checkoutLatest(): Promise<void>;
235
243
  /**
@@ -245,8 +253,6 @@ export declare class Table {
245
253
  * out state and the read_consistency_interval, if any, will apply.
246
254
  */
247
255
  restore(): Promise<void>;
248
- /**
249
- * List all indices that have been created with Self::create_index
250
- */
256
+ /** List all indices that have been created with {@link Table.createIndex} */
251
257
  listIndices(): Promise<IndexConfig[]>;
252
258
  }
package/dist/table.js CHANGED
@@ -123,17 +123,20 @@ class Table {
123
123
  * // If the column has a vector (fixed size list) data type then
124
124
  * // an IvfPq vector index will be created.
125
125
  * const table = await conn.openTable("my_table");
126
- * await table.createIndex(["vector"]);
126
+ * await table.createIndex("vector");
127
127
  * @example
128
128
  * // For advanced control over vector index creation you can specify
129
129
  * // the index type and options.
130
130
  * const table = await conn.openTable("my_table");
131
- * await table.createIndex(["vector"], I)
132
- * .ivf_pq({ num_partitions: 128, num_sub_vectors: 16 })
133
- * .build();
131
+ * await table.createIndex("vector", {
132
+ * config: lancedb.Index.ivfPq({
133
+ * numPartitions: 128,
134
+ * numSubVectors: 16,
135
+ * }),
136
+ * });
134
137
  * @example
135
138
  * // Or create a Scalar index
136
- * await table.createIndex("my_float_col").build();
139
+ * await table.createIndex("my_float_col");
137
140
  */
138
141
  async createIndex(column, options) {
139
142
  // Bit of a hack to get around the fact that TS has no package-scope.
@@ -150,8 +153,7 @@ class Table {
150
153
  * vector similarity, sorting, and more.
151
154
  *
152
155
  * Note: By default, all columns are returned. For best performance, you should
153
- * only fetch the columns you need. See [`Query::select_with_projection`] for
154
- * more details.
156
+ * only fetch the columns you need.
155
157
  *
156
158
  * When appropriate, various indices and statistics based pruning will be used to
157
159
  * accelerate the query.
@@ -159,10 +161,13 @@ class Table {
159
161
  * // SQL-style filtering
160
162
  * //
161
163
  * // This query will return up to 1000 rows whose value in the `id` column
162
- * // is greater than 5. LanceDb supports a broad set of filtering functions.
163
- * for await (const batch of table.query()
164
- * .filter("id > 1").select(["id"]).limit(20)) {
165
- * console.log(batch);
164
+ * // is greater than 5. LanceDb supports a broad set of filtering functions.
165
+ * for await (const batch of table
166
+ * .query()
167
+ * .where("id > 1")
168
+ * .select(["id"])
169
+ * .limit(20)) {
170
+ * console.log(batch);
166
171
  * }
167
172
  * @example
168
173
  * // Vector Similarity Search
@@ -171,13 +176,14 @@ class Table {
171
176
  * // closest to the query vector [1.0, 2.0, 3.0]. If an index has been created
172
177
  * // on the "vector" column then this will perform an ANN search.
173
178
  * //
174
- * // The `refine_factor` and `nprobes` methods are used to control the recall /
179
+ * // The `refineFactor` and `nprobes` methods are used to control the recall /
175
180
  * // latency tradeoff of the search.
176
- * for await (const batch of table.query()
177
- * .nearestTo([1, 2, 3])
178
- * .refineFactor(5).nprobe(10)
179
- * .limit(10)) {
180
- * console.log(batch);
181
+ * for await (const batch of table
182
+ * .query()
183
+ * .where("id > 1")
184
+ * .select(["id"])
185
+ * .limit(20)) {
186
+ * console.log(batch);
181
187
  * }
182
188
  * @example
183
189
  * // Scan the full dataset
@@ -234,41 +240,43 @@ class Table {
234
240
  async dropColumns(columnNames) {
235
241
  await this.inner.dropColumns(columnNames);
236
242
  }
237
- /**
238
- * Retrieve the version of the table
239
- *
240
- * LanceDb supports versioning. Every operation that modifies the table increases
241
- * version. As long as a version hasn't been deleted you can `[Self::checkout]` that
242
- * version to view the data at that point. In addition, you can `[Self::restore]` the
243
- * version to replace the current table with a previous version.
244
- */
243
+ /** Retrieve the version of the table */
245
244
  async version() {
246
245
  return await this.inner.version();
247
246
  }
248
247
  /**
249
- * Checks out a specific version of the Table
248
+ * Checks out a specific version of the table _This is an in-place operation._
250
249
  *
251
- * Any read operation on the table will now access the data at the checked out version.
252
- * As a consequence, calling this method will disable any read consistency interval
253
- * that was previously set.
250
+ * This allows viewing previous versions of the table. If you wish to
251
+ * keep writing to the dataset starting from an old version, then use
252
+ * the `restore` function.
254
253
  *
255
- * This is a read-only operation that turns the table into a sort of "view"
256
- * or "detached head". Other table instances will not be affected. To make the change
257
- * permanent you can use the `[Self::restore]` method.
258
- *
259
- * Any operation that modifies the table will fail while the table is in a checked
260
- * out state.
254
+ * Calling this method will set the table into time-travel mode. If you
255
+ * wish to return to standard mode, call `checkoutLatest`.
256
+ * @param {number} version The version to checkout
257
+ * @example
258
+ * ```typescript
259
+ * import * as lancedb from "@lancedb/lancedb"
260
+ * const db = await lancedb.connect("./.lancedb");
261
+ * const table = await db.createTable("my_table", [
262
+ * { vector: [1.1, 0.9], type: "vector" },
263
+ * ]);
261
264
  *
262
- * To return the table to a normal state use `[Self::checkout_latest]`
265
+ * console.log(await table.version()); // 1
266
+ * console.log(table.display());
267
+ * await table.add([{ vector: [0.5, 0.2], type: "vector" }]);
268
+ * await table.checkout(1);
269
+ * console.log(await table.version()); // 2
270
+ * ```
263
271
  */
264
272
  async checkout(version) {
265
273
  await this.inner.checkout(version);
266
274
  }
267
275
  /**
268
- * Ensures the table is pointing at the latest version
276
+ * Checkout the latest version of the table. _This is an in-place operation._
269
277
  *
270
- * This can be used to manually update a table when the read_consistency_interval is None
271
- * It can also be used to undo a `[Self::checkout]` operation
278
+ * The table will be set back into standard mode, and will track the latest
279
+ * version of the table.
272
280
  */
273
281
  async checkoutLatest() {
274
282
  await this.inner.checkoutLatest();
@@ -288,9 +296,7 @@ class Table {
288
296
  async restore() {
289
297
  await this.inner.restore();
290
298
  }
291
- /**
292
- * List all indices that have been created with Self::create_index
293
- */
299
+ /** List all indices that have been created with {@link Table.createIndex} */
294
300
  async listIndices() {
295
301
  return await this.inner.listIndices();
296
302
  }