Skip to content

Commit bd470f7

Browse files
committed
add vector column/index doc, update singlestore doc to rm mysql-core
1 parent 810437f commit bd470f7

File tree

2 files changed

+116
-35
lines changed

2 files changed

+116
-35
lines changed

src/content/docs/column-types/singlestore.mdx

Lines changed: 90 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ A signed integer, stored in `0`, `1`, `2`, `3`, `4`, `6`, or `8` bytes depending
2020

2121
<Section>
2222
```typescript
23-
import { int, singlestoreTable } from "drizzle-orm/mysql-core";
23+
import { int, singlestoreTable } from "drizzle-orm/singlestore-core";
2424

2525
const table = singlestoreTable('table', {
2626
int: int()
@@ -38,7 +38,7 @@ CREATE TABLE `table` (
3838

3939
<Section>
4040
```typescript
41-
import { tinyint, singlestoreTable } from "drizzle-orm/mysql-core";
41+
import { tinyint, singlestoreTable } from "drizzle-orm/singlestore-core";
4242

4343
const table = singlestoreTable('table', {
4444
tinyint: tinyint()
@@ -56,7 +56,7 @@ CREATE TABLE `table` (
5656

5757
<Section>
5858
```typescript
59-
import { smallint, singlestoreTable } from "drizzle-orm/mysql-core";
59+
import { smallint, singlestoreTable } from "drizzle-orm/singlestore-core";
6060

6161
const table = singlestoreTable('table', {
6262
smallint: smallint()
@@ -74,7 +74,7 @@ CREATE TABLE `table` (
7474

7575
<Section>
7676
```typescript
77-
import { mediumint, singlestoreTable } from "drizzle-orm/mysql-core";
77+
import { mediumint, singlestoreTable } from "drizzle-orm/singlestore-core";
7878

7979
const table = singlestoreTable('table', {
8080
mediumint: mediumint()
@@ -92,7 +92,7 @@ CREATE TABLE `table` (
9292

9393
<Section>
9494
```typescript
95-
import { bigint, singlestoreTable } from "drizzle-orm/mysql-core";
95+
import { bigint, singlestoreTable } from "drizzle-orm/singlestore-core";
9696

9797
const table = singlestoreTable('table', {
9898
bigint: bigint({ mode: 'number' })
@@ -121,7 +121,7 @@ We've omitted config of `M` in `bigint(M)`, since it indicates the display width
121121

122122
<Section>
123123
```typescript
124-
import { real, singlestoreTable } from "drizzle-orm/mysql-core";
124+
import { real, singlestoreTable } from "drizzle-orm/singlestore-core";
125125

126126
const table = singlestoreTable('table', {
127127
real: real()
@@ -137,7 +137,7 @@ CREATE TABLE `table` (
137137

138138
<Section>
139139
```typescript
140-
import { real, singlestoreTable } from "drizzle-orm/mysql-core";
140+
import { real, singlestoreTable } from "drizzle-orm/singlestore-core";
141141

142142
const table = singlestoreTable('table', {
143143
realPrecision: real({ precision: 1,}),
@@ -157,7 +157,7 @@ CREATE TABLE `table` (
157157

158158
<Section>
159159
```typescript
160-
import { decimal, singlestoreTable } from "drizzle-orm/mysql-core";
160+
import { decimal, singlestoreTable } from "drizzle-orm/singlestore-core";
161161

162162
const table = singlestoreTable('table', {
163163
decimal: decimal()
@@ -173,7 +173,7 @@ CREATE TABLE `table` (
173173

174174
<Section>
175175
```typescript
176-
import { decimal, singlestoreTable } from "drizzle-orm/mysql-core";
176+
import { decimal, singlestoreTable } from "drizzle-orm/singlestore-core";
177177

178178
const table = singlestoreTable('table', {
179179
decimalPrecision: decimal({ precision: 1,}),
@@ -193,7 +193,7 @@ CREATE TABLE `table` (
193193

194194
<Section>
195195
```typescript
196-
import { double, singlestoreTable } from "drizzle-orm/mysql-core";
196+
import { double, singlestoreTable } from "drizzle-orm/singlestore-core";
197197

198198
const table = singlestoreTable('table', {
199199
double: double('double')
@@ -209,7 +209,7 @@ CREATE TABLE `table` (
209209

210210
<Section>
211211
```typescript
212-
import { double, singlestoreTable } from "drizzle-orm/mysql-core";
212+
import { double, singlestoreTable } from "drizzle-orm/singlestore-core";
213213

214214
const table = singlestoreTable('table', {
215215
doublePrecision: double({ precision: 1,}),
@@ -229,7 +229,7 @@ CREATE TABLE `table` (
229229

230230
<Section>
231231
```typescript
232-
import { float, singlestoreTable } from "drizzle-orm/mysql-core";
232+
import { float, singlestoreTable } from "drizzle-orm/singlestore-core";
233233

234234
const table = singlestoreTable('table', {
235235
float: float()
@@ -252,7 +252,7 @@ CREATE TABLE `table` (
252252
`SERIAL` is an alias for `BIGINT UNSIGNED NOT NULL AUTO_INCREMENT UNIQUE`.
253253

254254
```typescript
255-
import { serial, singlestoreTable } from "drizzle-orm/mysql-core";
255+
import { serial, singlestoreTable } from "drizzle-orm/singlestore-core";
256256

257257
const table = singlestoreTable('table', {
258258
serial: serial()
@@ -272,7 +272,7 @@ CREATE TABLE `table` (
272272

273273
<Section>
274274
```typescript
275-
import { binary, singlestoreTable } from "drizzle-orm/mysql-core";
275+
import { binary, singlestoreTable } from "drizzle-orm/singlestore-core";
276276

277277
const table = singlestoreTable('table', {
278278
binary: binary()
@@ -290,7 +290,7 @@ CREATE TABLE `table` (
290290

291291
<Section>
292292
```typescript
293-
import { varbinary, singlestoreTable } from "drizzle-orm/mysql-core";
293+
import { varbinary, singlestoreTable } from "drizzle-orm/singlestore-core";
294294

295295
const table = singlestoreTable('table', {
296296
varbinary: varbinary({ length: 2}),
@@ -310,7 +310,7 @@ CREATE TABLE `table` (
310310

311311
<Section>
312312
```typescript
313-
import { char, singlestoreTable } from "drizzle-orm/mysql-core";
313+
import { char, singlestoreTable } from "drizzle-orm/singlestore-core";
314314

315315
const table = singlestoreTable('table', {
316316
char: char(),
@@ -328,7 +328,7 @@ CREATE TABLE `table` (
328328
You can define `{ enum: ["value1", "value2"] }` config to infer `insert` and `select` types, it **won't** check runtime values.
329329
<Section>
330330
```typescript
331-
import { varchar, singlestoreTable } from "drizzle-orm/mysql-core";
331+
import { varchar, singlestoreTable } from "drizzle-orm/singlestore-core";
332332

333333
const table = singlestoreTable('table', {
334334
varchar: varchar({ length: 2 }),
@@ -351,7 +351,7 @@ You can define `{ enum: ["value1", "value2"] }` config to infer `insert` and `se
351351

352352
<Section>
353353
```typescript
354-
import { text, singlestoreTable } from "drizzle-orm/mysql-core";
354+
import { text, singlestoreTable } from "drizzle-orm/singlestore-core";
355355

356356
const table = singlestoreTable('table', {
357357
text: text(),
@@ -374,7 +374,7 @@ CREATE TABLE `table` (
374374

375375
<Section>
376376
```typescript
377-
import { boolean, singlestoreTable } from "drizzle-orm/mysql-core";
377+
import { boolean, singlestoreTable } from "drizzle-orm/singlestore-core";
378378

379379
const table = singlestoreTable('table', {
380380
boolean: boolean(),
@@ -394,7 +394,7 @@ CREATE TABLE `table` (
394394

395395
<Section>
396396
```typescript
397-
import { boolean, singlestoreTable } from "drizzle-orm/mysql-core";
397+
import { boolean, singlestoreTable } from "drizzle-orm/singlestore-core";
398398

399399
const table = singlestoreTable('table', {
400400
date: date(),
@@ -412,7 +412,7 @@ CREATE TABLE `table` (
412412

413413
<Section>
414414
```typescript
415-
import { datetime, singlestoreTable } from "drizzle-orm/mysql-core";
415+
import { datetime, singlestoreTable } from "drizzle-orm/singlestore-core";
416416

417417
const table = singlestoreTable('table', {
418418
datetime: datetime(),
@@ -432,7 +432,7 @@ CREATE TABLE `table` (
432432

433433
<Section>
434434
```typescript
435-
import { time, singlestoreTable } from "drizzle-orm/mysql-core";
435+
import { time, singlestoreTable } from "drizzle-orm/singlestore-core";
436436

437437
const table = singlestoreTable('table', {
438438
time: time(),
@@ -450,7 +450,7 @@ CREATE TABLE `table` (
450450

451451
<Section>
452452
```typescript
453-
import { year, singlestoreTable } from "drizzle-orm/mysql-core";
453+
import { year, singlestoreTable } from "drizzle-orm/singlestore-core";
454454

455455
const table = singlestoreTable('table', {
456456
year: year(),
@@ -468,7 +468,7 @@ CREATE TABLE `table` (
468468

469469
<Section>
470470
```typescript
471-
import { timestamp, singlestoreTable } from "drizzle-orm/mysql-core";
471+
import { timestamp, singlestoreTable } from "drizzle-orm/singlestore-core";
472472

473473
const table = singlestoreTable('table', {
474474
timestamp: timestamp(),
@@ -486,7 +486,7 @@ CREATE TABLE `table` (
486486

487487
<Section>
488488
```typescript
489-
import { timestamp, singlestoreTable } from "drizzle-orm/mysql-core";
489+
import { timestamp, singlestoreTable } from "drizzle-orm/singlestore-core";
490490

491491
const table = singlestoreTable('table', {
492492
timestamp: timestamp().defaultNow(),
@@ -506,7 +506,7 @@ CREATE TABLE `table` (
506506

507507
<Section>
508508
```typescript
509-
import { json, singlestoreTable } from "drizzle-orm/mysql-core";
509+
import { json, singlestoreTable } from "drizzle-orm/singlestore-core";
510510

511511
const table = singlestoreTable('table', {
512512
json: json(),
@@ -540,10 +540,10 @@ json: json().$type<string[]>().default({});
540540

541541
<Section>
542542
```typescript
543-
import { mysqlEnum, singlestoreTable } from "drizzle-orm/mysql-core";
543+
import { singlestoreEnum, singlestoreTable } from "drizzle-orm/singlestore-core";
544544

545545
const table = singlestoreTable('table', {
546-
mysqlEnum: mysqlEnum(['unknown', 'known', 'popular']),
546+
singlestoreEnum: singlestoreEnum(['unknown', 'known', 'popular']),
547547
});
548548
```
549549

@@ -556,6 +556,62 @@ CREATE TABLE `table` (
556556

557557
## ---
558558

559+
### vector
560+
561+
<Section>
562+
```typescript
563+
import { singlestoreTable, vector } from "drizzle-orm/singlestore-core";
564+
565+
const table = singlestoreTable('table', {
566+
embedding: vector("embedding", { dimensions: 10 }),
567+
});
568+
```
569+
570+
```sql
571+
CREATE TABLE `table` (
572+
`embedding` vector(10)
573+
);
574+
```
575+
</Section>
576+
577+
You can specify `elementType` in order to change what element type the vector
578+
consists of. This can be one of `I8`, `I16`, `I32`, `I64`, `F32`, or `F64`
579+
580+
<Section>
581+
```typescript
582+
import { singlestoreTable, vector } from "drizzle-orm/singlestore-core";
583+
584+
const table = singlestoreTable('table', {
585+
embedding: vector("embedding", { dimensions: 10, elementType: 'I8' }),
586+
});
587+
```
588+
589+
```sql
590+
CREATE TABLE `table` (
591+
`embedding` vector(10, 'I8')
592+
);
593+
```
594+
</Section>
595+
596+
###### Helper functions
597+
598+
There are two helper functions useful for vector search queries in SingleStore:
599+
600+
<Section>
601+
```typescript
602+
import { dotProduct, euclideanDistance } from 'drizzle-orm/singlestore-core/expressions';
603+
604+
euclideanDistance(table.column, [3, 1, 2]);
605+
dotProduct(table.column, [3, 1, 2]);
606+
```
607+
```sql
608+
table.column <-> '[3, 1, 2]'
609+
table.column <*> '[3, 1, 2]`
610+
```
611+
</Section>
612+
613+
## ---
614+
559615
### Customizing data type
560616
561617
Every column builder has a `.$type()` method, which allows you to customize the data type of the column. This is useful, for example, with unknown or branded types.
@@ -578,7 +634,7 @@ const users = singlestoreTable('users', {
578634
579635
<Section>
580636
```typescript
581-
import { int, singlestoreTable } from "drizzle-orm/mysql-core";
637+
import { int, singlestoreTable } from "drizzle-orm/singlestore-core";
582638
583639
const table = singlestoreTable('table', {
584640
int: int().notNull(),
@@ -604,7 +660,7 @@ a string constant, a blob constant, a signed-number, or any constant expression
604660
605661
<Section>
606662
```typescript
607-
import { int, singlestoreTable } from "drizzle-orm/mysql-core";
663+
import { int, singlestoreTable } from "drizzle-orm/singlestore-core";
608664
609665
const table = singlestoreTable('table', {
610666
int: int().default(3),
@@ -627,7 +683,7 @@ These functions can assist you in utilizing various implementations such as `uui
627683
</Callout>
628684
629685
```ts
630-
import { varchar, singlestoreTable } from "drizzle-orm/mysql-core";
686+
import { varchar, singlestoreTable } from "drizzle-orm/singlestore-core";
631687
import { createId } from '@paralleldrive/cuid2';
632688
633689
const table = singlestoreTable('table', {
@@ -648,7 +704,7 @@ when the row is inserted as well, and the returned value will be used as the col
648704
</Callout>
649705
650706
```ts
651-
import { text, singlestoreTable } from "drizzle-orm/mysql-core";
707+
import { text, singlestoreTable } from "drizzle-orm/singlestore-core";
652708
653709
const table = singlestoreTable('table', {
654710
alwaysNull: text().$type<string | null>().$onUpdate(() => null),
@@ -659,7 +715,7 @@ const table = singlestoreTable('table', {
659715
660716
<Section>
661717
```typescript
662-
import { int, singlestoreTable } from "drizzle-orm/mysql-core";
718+
import { int, singlestoreTable } from "drizzle-orm/singlestore-core";
663719
664720
const table = singlestoreTable('table', {
665721
int: int().primaryKey(),
@@ -677,7 +733,7 @@ CREATE TABLE `table` (
677733
678734
<Section>
679735
```typescript
680-
import { int, singlestoreTable } from "drizzle-orm/mysql-core";
736+
import { int, singlestoreTable } from "drizzle-orm/singlestore-core";
681737
682738
const table = singlestoreTable('table', {
683739
int: int().autoincrement(),

0 commit comments

Comments
 (0)