| 1 | [vectordb](../README.md) / [Exports](../modules.md) / Connection |
| 2 | |
| 3 | # Interface: Connection |
| 4 | |
| 5 | A LanceDB Connection that allows you to open tables and create new ones. |
| 6 | |
| 7 | Connection could be local against filesystem or remote against a server. |
| 8 | |
| 9 | ## Implemented by |
| 10 | |
| 11 | - [`LocalConnection`](../classes/LocalConnection.md) |
| 12 | |
| 13 | ## Table of contents |
| 14 | |
| 15 | ### Properties |
| 16 | |
| 17 | - [uri](Connection.md#uri) |
| 18 | |
| 19 | ### Methods |
| 20 | |
| 21 | - [createTable](Connection.md#createtable) |
| 22 | - [dropTable](Connection.md#droptable) |
| 23 | - [openTable](Connection.md#opentable) |
| 24 | - [tableNames](Connection.md#tablenames) |
| 25 | - [withMiddleware](Connection.md#withmiddleware) |
| 26 | |
| 27 | ## Properties |
| 28 | |
| 29 | ### uri |
| 30 | |
| 31 | • **uri**: `string` |
| 32 | |
| 33 | #### Defined in |
| 34 | |
| 35 | [index.ts:261](https://github.com/lancedb/lancedb/blob/92179835/node/src/index.ts#L261) |
| 36 | |
| 37 | ## Methods |
| 38 | |
| 39 | ### createTable |
| 40 | |
| 41 | ▸ **createTable**\<`T`\>(`«destructured»`): `Promise`\<[`Table`](Table.md)\<`T`\>\> |
| 42 | |
| 43 | Creates a new Table, optionally initializing it with new data. |
| 44 | |
| 45 | #### Type parameters |
| 46 | |
| 47 | | Name | |
| 48 | | :------ | |
| 49 | | `T` | |
| 50 | |
| 51 | #### Parameters |
| 52 | |
| 53 | | Name | Type | |
| 54 | | :------ | :------ | |
| 55 | | `«destructured»` | [`CreateTableOptions`](CreateTableOptions.md)\<`T`\> | |
| 56 | |
| 57 | #### Returns |
| 58 | |
| 59 | `Promise`\<[`Table`](Table.md)\<`T`\>\> |
| 60 | |
| 61 | #### Defined in |
| 62 | |
| 63 | [index.ts:285](https://github.com/lancedb/lancedb/blob/92179835/node/src/index.ts#L285) |
| 64 | |
| 65 | ▸ **createTable**(`name`, `data`): `Promise`\<[`Table`](Table.md)\<`number`[]\>\> |
| 66 | |
| 67 | Creates a new Table and initialize it with new data. |
| 68 | |
| 69 | #### Parameters |
| 70 | |
| 71 | | Name | Type | Description | |
| 72 | | :------ | :------ | :------ | |
| 73 | | `name` | `string` | The name of the table. | |
| 74 | | `data` | `Table`\<`any`\> \| `Record`\<`string`, `unknown`\>[] | Non-empty Array of Records to be inserted into the table | |
| 75 | |
| 76 | #### Returns |
| 77 | |
| 78 | `Promise`\<[`Table`](Table.md)\<`number`[]\>\> |
| 79 | |
| 80 | #### Defined in |
| 81 | |
| 82 | [index.ts:299](https://github.com/lancedb/lancedb/blob/92179835/node/src/index.ts#L299) |
| 83 | |
| 84 | ▸ **createTable**(`name`, `data`, `options`): `Promise`\<[`Table`](Table.md)\<`number`[]\>\> |
| 85 | |
| 86 | Creates a new Table and initialize it with new data. |
| 87 | |
| 88 | #### Parameters |
| 89 | |
| 90 | | Name | Type | Description | |
| 91 | | :------ | :------ | :------ | |
| 92 | | `name` | `string` | The name of the table. | |
| 93 | | `data` | `Table`\<`any`\> \| `Record`\<`string`, `unknown`\>[] | Non-empty Array of Records to be inserted into the table | |
| 94 | | `options` | [`WriteOptions`](WriteOptions.md) | The write options to use when creating the table. | |
| 95 | |
| 96 | #### Returns |
| 97 | |
| 98 | `Promise`\<[`Table`](Table.md)\<`number`[]\>\> |
| 99 | |
| 100 | #### Defined in |
| 101 | |
| 102 | [index.ts:311](https://github.com/lancedb/lancedb/blob/92179835/node/src/index.ts#L311) |
| 103 | |
| 104 | ▸ **createTable**\<`T`\>(`name`, `data`, `embeddings`): `Promise`\<[`Table`](Table.md)\<`T`\>\> |
| 105 | |
| 106 | Creates a new Table and initialize it with new data. |
| 107 | |
| 108 | #### Type parameters |
| 109 | |
| 110 | | Name | |
| 111 | | :------ | |
| 112 | | `T` | |
| 113 | |
| 114 | #### Parameters |
| 115 | |
| 116 | | Name | Type | Description | |
| 117 | | :------ | :------ | :------ | |
| 118 | | `name` | `string` | The name of the table. | |
| 119 | | `data` | `Table`\<`any`\> \| `Record`\<`string`, `unknown`\>[] | Non-empty Array of Records to be inserted into the table | |
| 120 | | `embeddings` | [`EmbeddingFunction`](EmbeddingFunction.md)\<`T`\> | An embedding function to use on this table | |
| 121 | |
| 122 | #### Returns |
| 123 | |
| 124 | `Promise`\<[`Table`](Table.md)\<`T`\>\> |
| 125 | |
| 126 | #### Defined in |
| 127 | |
| 128 | [index.ts:324](https://github.com/lancedb/lancedb/blob/92179835/node/src/index.ts#L324) |
| 129 | |
| 130 | ▸ **createTable**\<`T`\>(`name`, `data`, `embeddings`, `options`): `Promise`\<[`Table`](Table.md)\<`T`\>\> |
| 131 | |
| 132 | Creates a new Table and initialize it with new data. |
| 133 | |
| 134 | #### Type parameters |
| 135 | |
| 136 | | Name | |
| 137 | | :------ | |
| 138 | | `T` | |
| 139 | |
| 140 | #### Parameters |
| 141 | |
| 142 | | Name | Type | Description | |
| 143 | | :------ | :------ | :------ | |
| 144 | | `name` | `string` | The name of the table. | |
| 145 | | `data` | `Table`\<`any`\> \| `Record`\<`string`, `unknown`\>[] | Non-empty Array of Records to be inserted into the table | |
| 146 | | `embeddings` | [`EmbeddingFunction`](EmbeddingFunction.md)\<`T`\> | An embedding function to use on this table | |
| 147 | | `options` | [`WriteOptions`](WriteOptions.md) | The write options to use when creating the table. | |
| 148 | |
| 149 | #### Returns |
| 150 | |
| 151 | `Promise`\<[`Table`](Table.md)\<`T`\>\> |
| 152 | |
| 153 | #### Defined in |
| 154 | |
| 155 | [index.ts:337](https://github.com/lancedb/lancedb/blob/92179835/node/src/index.ts#L337) |
| 156 | |
| 157 | ___ |
| 158 | |
| 159 | ### dropTable |
| 160 | |
| 161 | ▸ **dropTable**(`name`): `Promise`\<`void`\> |
| 162 | |
| 163 | Drop an existing table. |
| 164 | |
| 165 | #### Parameters |
| 166 | |
| 167 | | Name | Type | Description | |
| 168 | | :------ | :------ | :------ | |
| 169 | | `name` | `string` | The name of the table to drop. | |
| 170 | |
| 171 | #### Returns |
| 172 | |
| 173 | `Promise`\<`void`\> |
| 174 | |
| 175 | #### Defined in |
| 176 | |
| 177 | [index.ts:348](https://github.com/lancedb/lancedb/blob/92179835/node/src/index.ts#L348) |
| 178 | |
| 179 | ___ |
| 180 | |
| 181 | ### openTable |
| 182 | |
| 183 | ▸ **openTable**\<`T`\>(`name`, `embeddings?`): `Promise`\<[`Table`](Table.md)\<`T`\>\> |
| 184 | |
| 185 | Open a table in the database. |
| 186 | |
| 187 | #### Type parameters |
| 188 | |
| 189 | | Name | |
| 190 | | :------ | |
| 191 | | `T` | |
| 192 | |
| 193 | #### Parameters |
| 194 | |
| 195 | | Name | Type | Description | |
| 196 | | :------ | :------ | :------ | |
| 197 | | `name` | `string` | The name of the table. | |
| 198 | | `embeddings?` | [`EmbeddingFunction`](EmbeddingFunction.md)\<`T`\> | An embedding function to use on this table | |
| 199 | |
| 200 | #### Returns |
| 201 | |
| 202 | `Promise`\<[`Table`](Table.md)\<`T`\>\> |
| 203 | |
| 204 | #### Defined in |
| 205 | |
| 206 | [index.ts:271](https://github.com/lancedb/lancedb/blob/92179835/node/src/index.ts#L271) |
| 207 | |
| 208 | ___ |
| 209 | |
| 210 | ### tableNames |
| 211 | |
| 212 | ▸ **tableNames**(): `Promise`\<`string`[]\> |
| 213 | |
| 214 | #### Returns |
| 215 | |
| 216 | `Promise`\<`string`[]\> |
| 217 | |
| 218 | #### Defined in |
| 219 | |
| 220 | [index.ts:263](https://github.com/lancedb/lancedb/blob/92179835/node/src/index.ts#L263) |
| 221 | |
| 222 | ___ |
| 223 | |
| 224 | ### withMiddleware |
| 225 | |
| 226 | ▸ **withMiddleware**(`middleware`): [`Connection`](Connection.md) |
| 227 | |
| 228 | Instrument the behavior of this Connection with middleware. |
| 229 | |
| 230 | The middleware will be called in the order they are added. |
| 231 | |
| 232 | Currently this functionality is only supported for remote Connections. |
| 233 | |
| 234 | #### Parameters |
| 235 | |
| 236 | | Name | Type | |
| 237 | | :------ | :------ | |
| 238 | | `middleware` | `HttpMiddleware` | |
| 239 | |
| 240 | #### Returns |
| 241 | |
| 242 | [`Connection`](Connection.md) |
| 243 | |
| 244 | - this Connection instrumented by the passed middleware |
| 245 | |
| 246 | #### Defined in |
| 247 | |
| 248 | [index.ts:360](https://github.com/lancedb/lancedb/blob/92179835/node/src/index.ts#L360) |