drizzle-orm 0.31.2-5b29cb4 → 0.31.2-aaea9bd

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.
Files changed (39) hide show
  1. package/expo-sqlite/index.cjs +2 -0
  2. package/expo-sqlite/index.cjs.map +1 -1
  3. package/expo-sqlite/index.d.cts +1 -0
  4. package/expo-sqlite/index.d.ts +1 -0
  5. package/expo-sqlite/index.js +1 -0
  6. package/expo-sqlite/index.js.map +1 -1
  7. package/expo-sqlite/query.cjs +69 -0
  8. package/expo-sqlite/query.cjs.map +1 -0
  9. package/expo-sqlite/query.d.cts +7 -0
  10. package/expo-sqlite/query.d.ts +7 -0
  11. package/expo-sqlite/query.js +45 -0
  12. package/expo-sqlite/query.js.map +1 -0
  13. package/package.json +25 -1
  14. package/sql/functions/full-text-search.cjs +75 -0
  15. package/sql/functions/full-text-search.cjs.map +1 -0
  16. package/sql/functions/full-text-search.d.cts +235 -0
  17. package/sql/functions/full-text-search.d.ts +235 -0
  18. package/sql/functions/full-text-search.js +44 -0
  19. package/sql/functions/full-text-search.js.map +1 -0
  20. package/sql/functions/index.cjs +2 -0
  21. package/sql/functions/index.cjs.map +1 -1
  22. package/sql/functions/index.d.cts +1 -0
  23. package/sql/functions/index.d.ts +1 -0
  24. package/sql/functions/index.js +1 -0
  25. package/sql/functions/index.js.map +1 -1
  26. package/sqlite-core/columns/text.cjs +30 -1
  27. package/sqlite-core/columns/text.cjs.map +1 -1
  28. package/sqlite-core/columns/text.d.cts +23 -2
  29. package/sqlite-core/columns/text.d.ts +23 -2
  30. package/sqlite-core/columns/text.js +28 -1
  31. package/sqlite-core/columns/text.js.map +1 -1
  32. package/sqlite-core/query-builders/query.cjs.map +1 -1
  33. package/sqlite-core/query-builders/query.d.cts +3 -2
  34. package/sqlite-core/query-builders/query.d.ts +3 -2
  35. package/sqlite-core/query-builders/query.js.map +1 -1
  36. package/version.cjs +1 -1
  37. package/version.d.cts +1 -1
  38. package/version.d.ts +1 -1
  39. package/version.js +1 -1
@@ -16,10 +16,12 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
16
16
  var expo_sqlite_exports = {};
17
17
  module.exports = __toCommonJS(expo_sqlite_exports);
18
18
  __reExport(expo_sqlite_exports, require("./driver.cjs"), module.exports);
19
+ __reExport(expo_sqlite_exports, require("./query.cjs"), module.exports);
19
20
  __reExport(expo_sqlite_exports, require("./session.cjs"), module.exports);
20
21
  // Annotate the CommonJS export names for ESM import in node:
21
22
  0 && (module.exports = {
22
23
  ...require("./driver.cjs"),
24
+ ...require("./query.cjs"),
23
25
  ...require("./session.cjs")
24
26
  });
25
27
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/expo-sqlite/index.ts"],"sourcesContent":["export * from './driver.ts';\nexport * from './session.ts';\n"],"mappings":";;;;;;;;;;;;;;;AAAA;AAAA;AAAA,gCAAc,wBAAd;AACA,gCAAc,yBADd;","names":[]}
1
+ {"version":3,"sources":["../../src/expo-sqlite/index.ts"],"sourcesContent":["export * from './driver.ts';\nexport * from './query.ts';\nexport * from './session.ts';\n"],"mappings":";;;;;;;;;;;;;;;AAAA;AAAA;AAAA,gCAAc,wBAAd;AACA,gCAAc,uBADd;AAEA,gCAAc,yBAFd;","names":[]}
@@ -1,2 +1,3 @@
1
1
  export * from "./driver.cjs";
2
+ export * from "./query.cjs";
2
3
  export * from "./session.cjs";
@@ -1,2 +1,3 @@
1
1
  export * from "./driver.js";
2
+ export * from "./query.js";
2
3
  export * from "./session.js";
@@ -1,3 +1,4 @@
1
1
  export * from "./driver.js";
2
+ export * from "./query.js";
2
3
  export * from "./session.js";
3
4
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/expo-sqlite/index.ts"],"sourcesContent":["export * from './driver.ts';\nexport * from './session.ts';\n"],"mappings":"AAAA,cAAc;AACd,cAAc;","names":[]}
1
+ {"version":3,"sources":["../../src/expo-sqlite/index.ts"],"sourcesContent":["export * from './driver.ts';\nexport * from './query.ts';\nexport * from './session.ts';\n"],"mappings":"AAAA,cAAc;AACd,cAAc;AACd,cAAc;","names":[]}
@@ -0,0 +1,69 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var query_exports = {};
20
+ __export(query_exports, {
21
+ useLiveQuery: () => useLiveQuery
22
+ });
23
+ module.exports = __toCommonJS(query_exports);
24
+ var import_next = require("expo-sqlite/next");
25
+ var import_react = require("react");
26
+ var import__ = require("../index.cjs");
27
+ var import_sqlite_core = require("../sqlite-core/index.cjs");
28
+ var import_query = require("../sqlite-core/query-builders/query.cjs");
29
+ const useLiveQuery = (query) => {
30
+ const [data, setData] = (0, import_react.useState)(
31
+ (0, import__.is)(query, import_query.SQLiteRelationalQuery) && query.mode === "first" ? void 0 : []
32
+ );
33
+ const [error, setError] = (0, import_react.useState)();
34
+ const [updatedAt, setUpdatedAt] = (0, import_react.useState)();
35
+ (0, import_react.useEffect)(() => {
36
+ const entity = (0, import__.is)(query, import_query.SQLiteRelationalQuery) ? query.table : query.config.table;
37
+ if ((0, import__.is)(entity, import__.Subquery) || (0, import__.is)(entity, import__.SQL)) {
38
+ setError(new Error("Selecting from subqueries and SQL are not supported in useLiveQuery"));
39
+ return;
40
+ }
41
+ let listener;
42
+ const handleData = (data2) => {
43
+ setData(data2);
44
+ setUpdatedAt(/* @__PURE__ */ new Date());
45
+ };
46
+ query.then(handleData).catch(setError);
47
+ if ((0, import__.is)(entity, import_sqlite_core.SQLiteTable) || (0, import__.is)(entity, import_sqlite_core.SQLiteView)) {
48
+ const config = (0, import__.is)(entity, import_sqlite_core.SQLiteTable) ? (0, import_sqlite_core.getTableConfig)(entity) : (0, import_sqlite_core.getViewConfig)(entity);
49
+ listener = (0, import_next.addDatabaseChangeListener)(({ tableName }) => {
50
+ if (config.name === tableName) {
51
+ query.then(handleData).catch(setError);
52
+ }
53
+ });
54
+ }
55
+ return () => {
56
+ listener?.remove();
57
+ };
58
+ }, []);
59
+ return {
60
+ data,
61
+ error,
62
+ updatedAt
63
+ };
64
+ };
65
+ // Annotate the CommonJS export names for ESM import in node:
66
+ 0 && (module.exports = {
67
+ useLiveQuery
68
+ });
69
+ //# sourceMappingURL=query.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/expo-sqlite/query.ts"],"sourcesContent":["import { addDatabaseChangeListener } from 'expo-sqlite/next';\nimport { useEffect, useState } from 'react';\nimport { is, SQL, Subquery } from '~/index.ts';\nimport type { AnySQLiteSelect } from '~/sqlite-core/index.ts';\nimport { getTableConfig, getViewConfig, SQLiteTable, SQLiteView } from '~/sqlite-core/index.ts';\nimport { SQLiteRelationalQuery } from '~/sqlite-core/query-builders/query.ts';\n\nexport const useLiveQuery = <T extends Pick<AnySQLiteSelect, '_' | 'then'> | SQLiteRelationalQuery<'sync', unknown>>(\n\tquery: T,\n) => {\n\tconst [data, setData] = useState<Awaited<T>>(\n\t\t(is(query, SQLiteRelationalQuery) && query.mode === 'first' ? undefined : []) as Awaited<T>,\n\t);\n\tconst [error, setError] = useState<Error>();\n\tconst [updatedAt, setUpdatedAt] = useState<Date>();\n\n\tuseEffect(() => {\n\t\tconst entity = is(query, SQLiteRelationalQuery) ? query.table : (query as AnySQLiteSelect).config.table;\n\n\t\tif (is(entity, Subquery) || is(entity, SQL)) {\n\t\t\tsetError(new Error('Selecting from subqueries and SQL are not supported in useLiveQuery'));\n\t\t\treturn;\n\t\t}\n\n\t\tlet listener: ReturnType<typeof addDatabaseChangeListener> | undefined;\n\n\t\tconst handleData = (data: any) => {\n\t\t\tsetData(data);\n\t\t\tsetUpdatedAt(new Date());\n\t\t};\n\n\t\tquery.then(handleData).catch(setError);\n\n\t\tif (is(entity, SQLiteTable) || is(entity, SQLiteView)) {\n\t\t\tconst config = is(entity, SQLiteTable) ? getTableConfig(entity) : getViewConfig(entity);\n\t\t\tlistener = addDatabaseChangeListener(({ tableName }) => {\n\t\t\t\tif (config.name === tableName) {\n\t\t\t\t\tquery.then(handleData).catch(setError);\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\n\t\treturn () => {\n\t\t\tlistener?.remove();\n\t\t};\n\t}, []);\n\n\treturn {\n\t\tdata,\n\t\terror,\n\t\tupdatedAt,\n\t} as const;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAA0C;AAC1C,mBAAoC;AACpC,eAAkC;AAElC,yBAAuE;AACvE,mBAAsC;AAE/B,MAAM,eAAe,CAC3B,UACI;AACJ,QAAM,CAAC,MAAM,OAAO,QAAI;AAAA,QACtB,aAAG,OAAO,kCAAqB,KAAK,MAAM,SAAS,UAAU,SAAY,CAAC;AAAA,EAC5E;AACA,QAAM,CAAC,OAAO,QAAQ,QAAI,uBAAgB;AAC1C,QAAM,CAAC,WAAW,YAAY,QAAI,uBAAe;AAEjD,8BAAU,MAAM;AACf,UAAM,aAAS,aAAG,OAAO,kCAAqB,IAAI,MAAM,QAAS,MAA0B,OAAO;AAElG,YAAI,aAAG,QAAQ,iBAAQ,SAAK,aAAG,QAAQ,YAAG,GAAG;AAC5C,eAAS,IAAI,MAAM,qEAAqE,CAAC;AACzF;AAAA,IACD;AAEA,QAAI;AAEJ,UAAM,aAAa,CAACA,UAAc;AACjC,cAAQA,KAAI;AACZ,mBAAa,oBAAI,KAAK,CAAC;AAAA,IACxB;AAEA,UAAM,KAAK,UAAU,EAAE,MAAM,QAAQ;AAErC,YAAI,aAAG,QAAQ,8BAAW,SAAK,aAAG,QAAQ,6BAAU,GAAG;AACtD,YAAM,aAAS,aAAG,QAAQ,8BAAW,QAAI,mCAAe,MAAM,QAAI,kCAAc,MAAM;AACtF,qBAAW,uCAA0B,CAAC,EAAE,UAAU,MAAM;AACvD,YAAI,OAAO,SAAS,WAAW;AAC9B,gBAAM,KAAK,UAAU,EAAE,MAAM,QAAQ;AAAA,QACtC;AAAA,MACD,CAAC;AAAA,IACF;AAEA,WAAO,MAAM;AACZ,gBAAU,OAAO;AAAA,IAClB;AAAA,EACD,GAAG,CAAC,CAAC;AAEL,SAAO;AAAA,IACN;AAAA,IACA;AAAA,IACA;AAAA,EACD;AACD;","names":["data"]}
@@ -0,0 +1,7 @@
1
+ import type { AnySQLiteSelect } from "../sqlite-core/index.cjs";
2
+ import { SQLiteRelationalQuery } from "../sqlite-core/query-builders/query.cjs";
3
+ export declare const useLiveQuery: <T extends Pick<AnySQLiteSelect, "_" | "then"> | SQLiteRelationalQuery<"sync", unknown>>(query: T) => {
4
+ readonly data: Awaited<T>;
5
+ readonly error: Error | undefined;
6
+ readonly updatedAt: Date | undefined;
7
+ };
@@ -0,0 +1,7 @@
1
+ import type { AnySQLiteSelect } from "../sqlite-core/index.js";
2
+ import { SQLiteRelationalQuery } from "../sqlite-core/query-builders/query.js";
3
+ export declare const useLiveQuery: <T extends Pick<AnySQLiteSelect, "_" | "then"> | SQLiteRelationalQuery<"sync", unknown>>(query: T) => {
4
+ readonly data: Awaited<T>;
5
+ readonly error: Error | undefined;
6
+ readonly updatedAt: Date | undefined;
7
+ };
@@ -0,0 +1,45 @@
1
+ import { addDatabaseChangeListener } from "expo-sqlite/next";
2
+ import { useEffect, useState } from "react";
3
+ import { is, SQL, Subquery } from "../index.js";
4
+ import { getTableConfig, getViewConfig, SQLiteTable, SQLiteView } from "../sqlite-core/index.js";
5
+ import { SQLiteRelationalQuery } from "../sqlite-core/query-builders/query.js";
6
+ const useLiveQuery = (query) => {
7
+ const [data, setData] = useState(
8
+ is(query, SQLiteRelationalQuery) && query.mode === "first" ? void 0 : []
9
+ );
10
+ const [error, setError] = useState();
11
+ const [updatedAt, setUpdatedAt] = useState();
12
+ useEffect(() => {
13
+ const entity = is(query, SQLiteRelationalQuery) ? query.table : query.config.table;
14
+ if (is(entity, Subquery) || is(entity, SQL)) {
15
+ setError(new Error("Selecting from subqueries and SQL are not supported in useLiveQuery"));
16
+ return;
17
+ }
18
+ let listener;
19
+ const handleData = (data2) => {
20
+ setData(data2);
21
+ setUpdatedAt(/* @__PURE__ */ new Date());
22
+ };
23
+ query.then(handleData).catch(setError);
24
+ if (is(entity, SQLiteTable) || is(entity, SQLiteView)) {
25
+ const config = is(entity, SQLiteTable) ? getTableConfig(entity) : getViewConfig(entity);
26
+ listener = addDatabaseChangeListener(({ tableName }) => {
27
+ if (config.name === tableName) {
28
+ query.then(handleData).catch(setError);
29
+ }
30
+ });
31
+ }
32
+ return () => {
33
+ listener?.remove();
34
+ };
35
+ }, []);
36
+ return {
37
+ data,
38
+ error,
39
+ updatedAt
40
+ };
41
+ };
42
+ export {
43
+ useLiveQuery
44
+ };
45
+ //# sourceMappingURL=query.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/expo-sqlite/query.ts"],"sourcesContent":["import { addDatabaseChangeListener } from 'expo-sqlite/next';\nimport { useEffect, useState } from 'react';\nimport { is, SQL, Subquery } from '~/index.ts';\nimport type { AnySQLiteSelect } from '~/sqlite-core/index.ts';\nimport { getTableConfig, getViewConfig, SQLiteTable, SQLiteView } from '~/sqlite-core/index.ts';\nimport { SQLiteRelationalQuery } from '~/sqlite-core/query-builders/query.ts';\n\nexport const useLiveQuery = <T extends Pick<AnySQLiteSelect, '_' | 'then'> | SQLiteRelationalQuery<'sync', unknown>>(\n\tquery: T,\n) => {\n\tconst [data, setData] = useState<Awaited<T>>(\n\t\t(is(query, SQLiteRelationalQuery) && query.mode === 'first' ? undefined : []) as Awaited<T>,\n\t);\n\tconst [error, setError] = useState<Error>();\n\tconst [updatedAt, setUpdatedAt] = useState<Date>();\n\n\tuseEffect(() => {\n\t\tconst entity = is(query, SQLiteRelationalQuery) ? query.table : (query as AnySQLiteSelect).config.table;\n\n\t\tif (is(entity, Subquery) || is(entity, SQL)) {\n\t\t\tsetError(new Error('Selecting from subqueries and SQL are not supported in useLiveQuery'));\n\t\t\treturn;\n\t\t}\n\n\t\tlet listener: ReturnType<typeof addDatabaseChangeListener> | undefined;\n\n\t\tconst handleData = (data: any) => {\n\t\t\tsetData(data);\n\t\t\tsetUpdatedAt(new Date());\n\t\t};\n\n\t\tquery.then(handleData).catch(setError);\n\n\t\tif (is(entity, SQLiteTable) || is(entity, SQLiteView)) {\n\t\t\tconst config = is(entity, SQLiteTable) ? getTableConfig(entity) : getViewConfig(entity);\n\t\t\tlistener = addDatabaseChangeListener(({ tableName }) => {\n\t\t\t\tif (config.name === tableName) {\n\t\t\t\t\tquery.then(handleData).catch(setError);\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\n\t\treturn () => {\n\t\t\tlistener?.remove();\n\t\t};\n\t}, []);\n\n\treturn {\n\t\tdata,\n\t\terror,\n\t\tupdatedAt,\n\t} as const;\n};\n"],"mappings":"AAAA,SAAS,iCAAiC;AAC1C,SAAS,WAAW,gBAAgB;AACpC,SAAS,IAAI,KAAK,gBAAgB;AAElC,SAAS,gBAAgB,eAAe,aAAa,kBAAkB;AACvE,SAAS,6BAA6B;AAE/B,MAAM,eAAe,CAC3B,UACI;AACJ,QAAM,CAAC,MAAM,OAAO,IAAI;AAAA,IACtB,GAAG,OAAO,qBAAqB,KAAK,MAAM,SAAS,UAAU,SAAY,CAAC;AAAA,EAC5E;AACA,QAAM,CAAC,OAAO,QAAQ,IAAI,SAAgB;AAC1C,QAAM,CAAC,WAAW,YAAY,IAAI,SAAe;AAEjD,YAAU,MAAM;AACf,UAAM,SAAS,GAAG,OAAO,qBAAqB,IAAI,MAAM,QAAS,MAA0B,OAAO;AAElG,QAAI,GAAG,QAAQ,QAAQ,KAAK,GAAG,QAAQ,GAAG,GAAG;AAC5C,eAAS,IAAI,MAAM,qEAAqE,CAAC;AACzF;AAAA,IACD;AAEA,QAAI;AAEJ,UAAM,aAAa,CAACA,UAAc;AACjC,cAAQA,KAAI;AACZ,mBAAa,oBAAI,KAAK,CAAC;AAAA,IACxB;AAEA,UAAM,KAAK,UAAU,EAAE,MAAM,QAAQ;AAErC,QAAI,GAAG,QAAQ,WAAW,KAAK,GAAG,QAAQ,UAAU,GAAG;AACtD,YAAM,SAAS,GAAG,QAAQ,WAAW,IAAI,eAAe,MAAM,IAAI,cAAc,MAAM;AACtF,iBAAW,0BAA0B,CAAC,EAAE,UAAU,MAAM;AACvD,YAAI,OAAO,SAAS,WAAW;AAC9B,gBAAM,KAAK,UAAU,EAAE,MAAM,QAAQ;AAAA,QACtC;AAAA,MACD,CAAC;AAAA,IACF;AAEA,WAAO,MAAM;AACZ,gBAAU,OAAO;AAAA,IAClB;AAAA,EACD,GAAG,CAAC,CAAC;AAEL,SAAO;AAAA,IACN;AAAA,IACA;AAAA,IACA;AAAA,EACD;AACD;","names":["data"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "drizzle-orm",
3
- "version": "0.31.2-5b29cb4",
3
+ "version": "0.31.2-aaea9bd",
4
4
  "description": "Drizzle ORM package for SQL databases",
5
5
  "type": "module",
6
6
  "scripts": {
@@ -656,6 +656,18 @@
656
656
  "types": "./expo-sqlite/migrator.d.ts",
657
657
  "default": "./expo-sqlite/migrator.js"
658
658
  },
659
+ "./expo-sqlite/query": {
660
+ "import": {
661
+ "types": "./expo-sqlite/query.d.ts",
662
+ "default": "./expo-sqlite/query.js"
663
+ },
664
+ "require": {
665
+ "types": "./expo-sqlite/query.d.cts",
666
+ "default": "./expo-sqlite/query.cjs"
667
+ },
668
+ "types": "./expo-sqlite/query.d.ts",
669
+ "default": "./expo-sqlite/query.js"
670
+ },
659
671
  "./expo-sqlite/session": {
660
672
  "import": {
661
673
  "types": "./expo-sqlite/session.d.ts",
@@ -3176,6 +3188,18 @@
3176
3188
  "types": "./sql/functions/aggregate.d.ts",
3177
3189
  "default": "./sql/functions/aggregate.js"
3178
3190
  },
3191
+ "./sql/functions/full-text-search": {
3192
+ "import": {
3193
+ "types": "./sql/functions/full-text-search.d.ts",
3194
+ "default": "./sql/functions/full-text-search.js"
3195
+ },
3196
+ "require": {
3197
+ "types": "./sql/functions/full-text-search.d.cts",
3198
+ "default": "./sql/functions/full-text-search.cjs"
3199
+ },
3200
+ "types": "./sql/functions/full-text-search.d.ts",
3201
+ "default": "./sql/functions/full-text-search.js"
3202
+ },
3179
3203
  "./sql/functions": {
3180
3204
  "import": {
3181
3205
  "types": "./sql/functions/index.d.ts",
@@ -0,0 +1,75 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var full_text_search_exports = {};
20
+ __export(full_text_search_exports, {
21
+ phraseto_tsquery: () => phraseto_tsquery,
22
+ plainto_tsquery: () => plainto_tsquery,
23
+ setweight: () => setweight,
24
+ to_tsquery: () => to_tsquery,
25
+ to_tsvector: () => to_tsvector,
26
+ ts_rank: () => ts_rank,
27
+ ts_rank_cd: () => ts_rank_cd,
28
+ websearch_to_tsquery: () => websearch_to_tsquery
29
+ });
30
+ module.exports = __toCommonJS(full_text_search_exports);
31
+ var import_sql = require("../sql.cjs");
32
+ function to_tsvector(arg1, arg2) {
33
+ return arg2 ? import_sql.sql`to_tsvector(${arg1}, ${arg2})` : import_sql.sql`to_tsvector(${arg1})`;
34
+ }
35
+ function to_tsquery(arg1, arg2) {
36
+ return arg2 ? import_sql.sql`to_tsquery(${arg1}, ${arg2})` : import_sql.sql`to_tsquery(${arg1})`;
37
+ }
38
+ function plainto_tsquery(arg1, arg2) {
39
+ return arg2 ? import_sql.sql`plainto_tsquery(${arg1}, ${arg2})` : import_sql.sql`plainto_tsquery(${arg1})`;
40
+ }
41
+ function phraseto_tsquery(arg1, arg2) {
42
+ return arg2 ? import_sql.sql`phraseto_tsquery(${arg1}, ${arg2})` : import_sql.sql`phraseto_tsquery(${arg1})`;
43
+ }
44
+ function websearch_to_tsquery(arg1, arg2) {
45
+ return arg2 ? import_sql.sql`websearch_to_tsquery(${arg1}, ${arg2})` : import_sql.sql`websearch_to_tsquery(${arg1})`;
46
+ }
47
+ function ts_rank(arg1, arg2, arg3, arg4) {
48
+ if (Array.isArray(arg1) && typeof arg2 !== "number" && arg3 !== void 0) {
49
+ return arg4 ? import_sql.sql`ts_rank(string_to_array(${arg1.join(",")}, ',')::float4[], ${arg2}, ${arg3}, ${arg4})` : import_sql.sql`ts_rank(string_to_array(${arg1.join(",")}, ',')::float4[], ${arg2}, ${arg3})`;
50
+ } else {
51
+ return arg3 ? import_sql.sql`ts_rank(${arg1}, ${arg2}, ${arg3})` : import_sql.sql`ts_rank(${arg1}, ${arg2})`;
52
+ }
53
+ }
54
+ function ts_rank_cd(arg1, arg2, arg3, arg4) {
55
+ if (Array.isArray(arg1) && typeof arg2 !== "number" && arg3 !== void 0) {
56
+ return arg4 ? import_sql.sql`ts_rank_cd(string_to_array(${arg1.join(",")}, ',')::float4[], ${arg2}, ${arg3}, ${arg4})` : import_sql.sql`ts_rank_cd(string_to_array(${arg1.join(",")}, ',')::float4[], ${arg2}, ${arg3})`;
57
+ } else {
58
+ return arg3 ? import_sql.sql`ts_rank_cd(${arg1}, ${arg2}, ${arg3})` : import_sql.sql`ts_rank_cd(${arg1}, ${arg2})`;
59
+ }
60
+ }
61
+ function setweight(vector, weight) {
62
+ return import_sql.sql`setweight(${vector}, ${weight})`;
63
+ }
64
+ // Annotate the CommonJS export names for ESM import in node:
65
+ 0 && (module.exports = {
66
+ phraseto_tsquery,
67
+ plainto_tsquery,
68
+ setweight,
69
+ to_tsquery,
70
+ to_tsvector,
71
+ ts_rank,
72
+ ts_rank_cd,
73
+ websearch_to_tsquery
74
+ });
75
+ //# sourceMappingURL=full-text-search.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/sql/functions/full-text-search.ts"],"sourcesContent":["import type { AnyPgColumn } from '~/pg-core/index.ts';\nimport { type SQL, sql } from '../sql.ts';\n\ntype Configuration =\n\t| 'simple'\n\t| 'arabic'\n\t| 'armenian'\n\t| 'basque'\n\t| 'catalan'\n\t| 'danish'\n\t| 'dutch'\n\t| 'english'\n\t| 'finnish'\n\t| 'french'\n\t| 'german'\n\t| 'greek'\n\t| 'hindi'\n\t| 'hungarian'\n\t| 'indonesian'\n\t| 'irish'\n\t| 'italian'\n\t| 'lithuanian'\n\t| 'nepali'\n\t| 'norwegian'\n\t| 'portuguese'\n\t| 'romanian'\n\t| 'serbian'\n\t| 'spanish'\n\t| 'swedish'\n\t| 'tamil'\n\t| 'turkish'\n\t| 'yiddish';\n\ntype Weight = 'A' | 'B' | 'C' | 'D';\n\n/**\n * Converts a document to the `tsvector` data type.\n *\n * @param {AnyPgColumn | string} document - The document to be converted into `tsvector`.\n * @returns {SQL}\n *\n * @example\n * ```ts\n * await db.select({ value: to_tsvector(posts.title) }).from(posts);\n * ```\n */\nexport function to_tsvector(document: AnyPgColumn | string): SQL;\n/**\n * Converts a document to the `tsvector` data type.\n *\n * @param {Configuration | string} configuration - Text search configuration (e.g., 'english', 'simple').\n * @param {AnyPgColumn | string} document - The document to be converted into `tsvector`.\n * @returns {SQL}\n *\n * @example\n * ```ts\n * await db.select({ value: to_tsvector('english', posts.title) }).from(posts);\n * ```\n */\nexport function to_tsvector(configuration: Configuration | string & {}, document: AnyPgColumn | string): SQL;\nexport function to_tsvector(arg1: Configuration | AnyPgColumn | string & {}, arg2?: AnyPgColumn | string): SQL {\n\treturn arg2 ? sql`to_tsvector(${arg1}, ${arg2})` : sql`to_tsvector(${arg1})`;\n}\n\n/**\n * Converts a query to the `tsquery` data type.\n *\n * @param {string} query - The text to be converted into `tsquery`.\n * @returns {SQL}\n *\n * @example\n * ```ts\n * await db.select().from(posts).where(sql`${to_tsvector(posts.title)} @@ ${to_tsquery('Drizzle')}`);\n * ```\n */\nexport function to_tsquery(query: string): SQL;\n/**\n * Converts a query to the `tsquery` data type.\n *\n * @param {Configuration | string} configuration - Text search configuration (e.g., 'english', 'simple').\n * @param {string} query - The text to be converted into `tsquery`.\n * @returns {SQL}\n *\n * @example\n * ```ts\n * await db.select().from(posts).where(sql`${to_tsvector('english', posts.title)} @@ ${to_tsquery('english', 'Drizzle')}`);\n * ```\n */\nexport function to_tsquery(configuration: Configuration | string & {}, query: string): SQL;\nexport function to_tsquery(arg1: Configuration | string & {}, arg2?: string): SQL {\n\treturn arg2 ? sql`to_tsquery(${arg1}, ${arg2})` : sql`to_tsquery(${arg1})`;\n}\n\n/**\n * Converts a query to the `tsquery` data type.\n *\n * The text is parsed and normalized much as for `to_tsvector`, then the `&` (AND) tsquery operator is inserted between surviving words.\n *\n * @param {string} query - The text to be converted into `tsquery`.\n * @returns {SQL}\n *\n * @example\n * ```ts\n * await db.select().from(posts).where(sql`${to_tsvector(posts.title)} @@ ${plainto_tsquery('PostgreSQL MySQL SQLite')}`);\n * ```\n */\nexport function plainto_tsquery(query: string): SQL;\n/**\n * Converts a query to the `tsquery` data type.\n *\n * The text is parsed and normalized much as for `to_tsvector`, then the `&` (AND) tsquery operator is inserted between surviving words.\n *\n * @param {Configuration | string} configuration - Text search configuration (e.g., 'english', 'simple').\n * @param {string} query - The text to be converted into `tsquery`.\n * @returns {SQL}\n *\n * @example\n * ```ts\n * await db.select().from(posts).where(sql`${to_tsvector('english', posts.title)} @@ ${plainto_tsquery('english', 'PostgreSQL MySQL SQLite')}`);\n * ```\n */\nexport function plainto_tsquery(configuration: Configuration | string & {}, query: string): SQL;\nexport function plainto_tsquery(arg1: Configuration | string & {}, arg2?: string): SQL {\n\treturn arg2 ? sql`plainto_tsquery(${arg1}, ${arg2})` : sql`plainto_tsquery(${arg1})`;\n}\n\n/**\n * Converts a query to the `tsquery` data type.\n *\n * `phraseto_tsquery` behaves much like `plainto_tsquery`, except that it inserts the `<->` (FOLLOWED BY) operator between surviving words instead of the `&` (AND) operator.\n *\n * @param {string} query - The text to be converted into `tsquery`.\n * @returns {SQL}\n *\n * @example\n * ```ts\n * await db.select().from(posts).where(sql`${to_tsvector(posts.title)} @@ ${phraseto_tsquery('Drizzle best practice')}`);\n * ```\n */\nexport function phraseto_tsquery(query: string): SQL;\n/**\n * Converts a query to the `tsquery` data type.\n *\n * `phraseto_tsquery` behaves much like `plainto_tsquery`, except that it inserts the `<->` (FOLLOWED BY) operator between surviving words instead of the `&` (AND) operator.\n *\n * @param {Configuration | string} configuration - Text search configuration (e.g., 'english', 'simple').\n * @param {string} query - The text to be converted into `tsquery`.\n * @returns {SQL}\n *\n * @example\n * ```ts\n * await db.select().from(posts).where(sql`${to_tsvector('english', posts.title)} @@ ${phraseto_tsquery('english', 'Drizzle best practice')}`);\n * ```\n */\nexport function phraseto_tsquery(configuration: Configuration | string & {}, query: string): SQL;\nexport function phraseto_tsquery(arg1: Configuration | string & {}, arg2?: string): SQL {\n\treturn arg2 ? sql`phraseto_tsquery(${arg1}, ${arg2})` : sql`phraseto_tsquery(${arg1})`;\n}\n\n/**\n * Converts a query to the `tsquery` data type.\n *\n * `websearch_to_tsquery` creates a `tsquery` value from querytext using an alternative syntax in which simple unformatted text is a valid query. Unlike `plainto_tsquery` and `phraseto_tsquery`, it also recognizes certain operators. Moreover, this function will never raise syntax errors, which makes it possible to use raw user-supplied input for search.\n *\n * @param {string} query - The text to be converted into `tsquery`.\n * @returns {SQL}\n *\n * @example\n * ```ts\n * await db.select().from(posts).where(sql`${to_tsvector(posts.title)} @@ ${websearch_to_tsquery('tips or updates Drizzle')}`);\n * ```\n */\nexport function websearch_to_tsquery(query: string): SQL;\n/**\n * Converts a query to the `tsquery` data type.\n *\n * `websearch_to_tsquery` creates a `tsquery` value from querytext using an alternative syntax in which simple unformatted text is a valid query. Unlike `plainto_tsquery` and `phraseto_tsquery`, it also recognizes certain operators. Moreover, this function will never raise syntax errors, which makes it possible to use raw user-supplied input for search.\n *\n * @param {Configuration | string} configuration - Text search configuration (e.g., 'english', 'simple').\n * @param {string} query - The text to be converted into `tsquery`.\n * @returns {SQL}\n *\n * @example\n * ```ts\n * await db.select().from(posts).where(sql`${to_tsvector('english', posts.title)} @@ ${websearch_to_tsquery('english', 'tips or updates Drizzle')}`);\n * ```\n */\nexport function websearch_to_tsquery(configuration: Configuration | string & {}, query: string): SQL;\nexport function websearch_to_tsquery(arg1: Configuration | string & {}, arg2?: string): SQL {\n\treturn arg2 ? sql`websearch_to_tsquery(${arg1}, ${arg2})` : sql`websearch_to_tsquery(${arg1})`;\n}\n\n/**\n * Calculates the text search rank of a document represented by a `tsvector` against a `tsquery`.\n *\n * @param {SQL} vector - The `tsvector` representation of the document.\n * @param {SQL} query - The `tsquery` to compare against the vector.\n * @param {number} [normalization] - Optional normalization parameter. Specifies whether and how a document's length should impact its rank.\n * @returns {SQL}\n *\n * @example\n * ```ts\n * const vector = to_tsvector('english', posts.title);\n * const query = to_tsquery('english', 'Drizzle');\n * const rank = ts_rank(vector, query);\n *\n * await db.select({ post: posts, rank }).from(posts).where(gt(rank, 0));\n * ```\n */\nexport function ts_rank(vector: SQL, query: SQL, normalization?: number): SQL;\n/**\n * Calculates the text search rank of a document represented by a `tsvector` against a `tsquery`, using weights.\n *\n * @param {number[]} weights - Array of weights applied to the document's components.\n * @param {SQL} vector - The `tsvector` representation of the document.\n * @param {SQL} query - The `tsquery` to compare against the vector.\n * @param {number} [normalization] - Optional normalization parameter. Specifies whether and how a document's length should impact its rank.\n * @returns {SQL}\n *\n * @example\n * ```ts\n * const weights = [0.1, 0.2, 0.4, 0.3];\n * const vector = to_tsvector('english', posts.title);\n * const query = to_tsquery('english', 'Drizzle');\n * const rank = ts_rank(weights, vector, query);\n *\n * await db.select({ post: posts, rank }).from(posts).where(gt(rank, 0));\n * ```\n */\nexport function ts_rank(weights: number[], vector: SQL, query: SQL, normalization?: number): SQL;\nexport function ts_rank(arg1: number[] | SQL, arg2: SQL | number, arg3?: SQL | number, arg4?: number): SQL {\n\tif (Array.isArray(arg1) && typeof arg2 !== 'number' && arg3 !== undefined) {\n\t\treturn arg4\n\t\t\t? sql`ts_rank(string_to_array(${arg1.join(',')}, ',')::float4[], ${arg2}, ${arg3}, ${arg4})`\n\t\t\t: sql`ts_rank(string_to_array(${arg1.join(',')}, ',')::float4[], ${arg2}, ${arg3})`;\n\t} else {\n\t\treturn arg3 ? sql`ts_rank(${arg1}, ${arg2}, ${arg3})` : sql`ts_rank(${arg1}, ${arg2})`;\n\t}\n}\n\n/**\n * Calculates the text search rank of a document with cover density ranking, represented by a `tsvector` against a `tsquery`.\n *\n * @param {SQL} vector - The `tsvector` representation of the document.\n * @param {SQL} query - The `tsquery` to compare against the vector.\n * @param {number} [normalization] - Optional normalization parameter. Specifies whether and how a document's length should impact its rank.\n * @returns {SQL}\n *\n * @example\n * ```ts\n * const vector = to_tsvector('english', posts.title);\n * const query = to_tsquery('english', 'Drizzle');\n * const rankCd = ts_rank_cd(vector, query);\n *\n * await db.select({ post: posts, rankCd }).from(posts).where(gt(rankCd, 0));\n * ```\n */\nexport function ts_rank_cd(vector: SQL, query: SQL, normalization?: number): SQL;\n/**\n * Calculates the text search rank of a document represented by a `tsvector` against a `tsquery`, using weights.\n *\n * @param {number[]} weights - Array of weights applied to the document's components.\n * @param {SQL} vector - The `tsvector` representation of the document.\n * @param {SQL} query - The `tsquery` to compare against the vector.\n * @param {number} [normalization] - Optional normalization parameter. Specifies whether and how a document's length should impact its rank.\n * @returns {SQL}\n *\n * @example\n * ```ts\n * const weights = [0.1, 0.2, 0.4, 0.3];\n * const vector = to_tsvector('english', posts.title);\n * const query = to_tsquery('english', 'Drizzle');\n * const rankCd = ts_rank_cd(weights, vector, query);\n *\n * await db.select({ post: posts, rankCd }).from(posts).where(gt(rankCd, 0));\n * ```\n */\nexport function ts_rank_cd(weights: number[], vector: SQL, query: SQL, normalization?: number): SQL;\nexport function ts_rank_cd(arg1: number[] | SQL, arg2: SQL | number, arg3?: SQL | number, arg4?: number): SQL {\n\tif (Array.isArray(arg1) && typeof arg2 !== 'number' && arg3 !== undefined) {\n\t\treturn arg4\n\t\t\t? sql`ts_rank_cd(string_to_array(${arg1.join(',')}, ',')::float4[], ${arg2}, ${arg3}, ${arg4})`\n\t\t\t: sql`ts_rank_cd(string_to_array(${arg1.join(',')}, ',')::float4[], ${arg2}, ${arg3})`;\n\t} else {\n\t\treturn arg3 ? sql`ts_rank_cd(${arg1}, ${arg2}, ${arg3})` : sql`ts_rank_cd(${arg1}, ${arg2})`;\n\t}\n}\n\n/**\n * Used to label the entries of a `tsvector` with a given weight, where a weight is one of the letters A, B, C, or D.\n *\n * @param {SQL} vector - The `tsvector` representation of the document.\n * @param {Weight} weight - The weight to be assigned to the elements of the vector.\n * @returns {SQL}\n *\n * @example\n * ```ts\n * const weightedVectorTitle = setweight(to_tsvector('english', posts.title), 'A');\n * const weightedVectorDescription = setweight(to_tsvector('english', posts.description), 'B');\n * const query = to_tsquery('english', 'Drizzle');\n *\n * await db.select().from(posts).where(sql`(${weightedVectorTitle} || ${weightedVectorDescription}) @@ ${query}`);\n * ```\n */\nexport function setweight(vector: SQL, weight: Weight | string & {}): SQL {\n\treturn sql`setweight(${vector}, ${weight})`;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,iBAA8B;AA2DvB,SAAS,YAAY,MAAiD,MAAkC;AAC9G,SAAO,OAAO,6BAAkB,IAAI,KAAK,IAAI,MAAM,6BAAkB,IAAI;AAC1E;AA2BO,SAAS,WAAW,MAAmC,MAAoB;AACjF,SAAO,OAAO,4BAAiB,IAAI,KAAK,IAAI,MAAM,4BAAiB,IAAI;AACxE;AA+BO,SAAS,gBAAgB,MAAmC,MAAoB;AACtF,SAAO,OAAO,iCAAsB,IAAI,KAAK,IAAI,MAAM,iCAAsB,IAAI;AAClF;AA+BO,SAAS,iBAAiB,MAAmC,MAAoB;AACvF,SAAO,OAAO,kCAAuB,IAAI,KAAK,IAAI,MAAM,kCAAuB,IAAI;AACpF;AA+BO,SAAS,qBAAqB,MAAmC,MAAoB;AAC3F,SAAO,OAAO,sCAA2B,IAAI,KAAK,IAAI,MAAM,sCAA2B,IAAI;AAC5F;AAwCO,SAAS,QAAQ,MAAsB,MAAoB,MAAqB,MAAoB;AAC1G,MAAI,MAAM,QAAQ,IAAI,KAAK,OAAO,SAAS,YAAY,SAAS,QAAW;AAC1E,WAAO,OACJ,yCAA8B,KAAK,KAAK,GAAG,CAAC,qBAAqB,IAAI,KAAK,IAAI,KAAK,IAAI,MACvF,yCAA8B,KAAK,KAAK,GAAG,CAAC,qBAAqB,IAAI,KAAK,IAAI;AAAA,EAClF,OAAO;AACN,WAAO,OAAO,yBAAc,IAAI,KAAK,IAAI,KAAK,IAAI,MAAM,yBAAc,IAAI,KAAK,IAAI;AAAA,EACpF;AACD;AAwCO,SAAS,WAAW,MAAsB,MAAoB,MAAqB,MAAoB;AAC7G,MAAI,MAAM,QAAQ,IAAI,KAAK,OAAO,SAAS,YAAY,SAAS,QAAW;AAC1E,WAAO,OACJ,4CAAiC,KAAK,KAAK,GAAG,CAAC,qBAAqB,IAAI,KAAK,IAAI,KAAK,IAAI,MAC1F,4CAAiC,KAAK,KAAK,GAAG,CAAC,qBAAqB,IAAI,KAAK,IAAI;AAAA,EACrF,OAAO;AACN,WAAO,OAAO,4BAAiB,IAAI,KAAK,IAAI,KAAK,IAAI,MAAM,4BAAiB,IAAI,KAAK,IAAI;AAAA,EAC1F;AACD;AAkBO,SAAS,UAAU,QAAa,QAAmC;AACzE,SAAO,2BAAgB,MAAM,KAAK,MAAM;AACzC;","names":[]}
@@ -0,0 +1,235 @@
1
+ import type { AnyPgColumn } from "../../pg-core/index.cjs";
2
+ import { type SQL } from "../sql.cjs";
3
+ type Configuration = 'simple' | 'arabic' | 'armenian' | 'basque' | 'catalan' | 'danish' | 'dutch' | 'english' | 'finnish' | 'french' | 'german' | 'greek' | 'hindi' | 'hungarian' | 'indonesian' | 'irish' | 'italian' | 'lithuanian' | 'nepali' | 'norwegian' | 'portuguese' | 'romanian' | 'serbian' | 'spanish' | 'swedish' | 'tamil' | 'turkish' | 'yiddish';
4
+ type Weight = 'A' | 'B' | 'C' | 'D';
5
+ /**
6
+ * Converts a document to the `tsvector` data type.
7
+ *
8
+ * @param {AnyPgColumn | string} document - The document to be converted into `tsvector`.
9
+ * @returns {SQL}
10
+ *
11
+ * @example
12
+ * ```ts
13
+ * await db.select({ value: to_tsvector(posts.title) }).from(posts);
14
+ * ```
15
+ */
16
+ export declare function to_tsvector(document: AnyPgColumn | string): SQL;
17
+ /**
18
+ * Converts a document to the `tsvector` data type.
19
+ *
20
+ * @param {Configuration | string} configuration - Text search configuration (e.g., 'english', 'simple').
21
+ * @param {AnyPgColumn | string} document - The document to be converted into `tsvector`.
22
+ * @returns {SQL}
23
+ *
24
+ * @example
25
+ * ```ts
26
+ * await db.select({ value: to_tsvector('english', posts.title) }).from(posts);
27
+ * ```
28
+ */
29
+ export declare function to_tsvector(configuration: Configuration | string & {}, document: AnyPgColumn | string): SQL;
30
+ /**
31
+ * Converts a query to the `tsquery` data type.
32
+ *
33
+ * @param {string} query - The text to be converted into `tsquery`.
34
+ * @returns {SQL}
35
+ *
36
+ * @example
37
+ * ```ts
38
+ * await db.select().from(posts).where(sql`${to_tsvector(posts.title)} @@ ${to_tsquery('Drizzle')}`);
39
+ * ```
40
+ */
41
+ export declare function to_tsquery(query: string): SQL;
42
+ /**
43
+ * Converts a query to the `tsquery` data type.
44
+ *
45
+ * @param {Configuration | string} configuration - Text search configuration (e.g., 'english', 'simple').
46
+ * @param {string} query - The text to be converted into `tsquery`.
47
+ * @returns {SQL}
48
+ *
49
+ * @example
50
+ * ```ts
51
+ * await db.select().from(posts).where(sql`${to_tsvector('english', posts.title)} @@ ${to_tsquery('english', 'Drizzle')}`);
52
+ * ```
53
+ */
54
+ export declare function to_tsquery(configuration: Configuration | string & {}, query: string): SQL;
55
+ /**
56
+ * Converts a query to the `tsquery` data type.
57
+ *
58
+ * The text is parsed and normalized much as for `to_tsvector`, then the `&` (AND) tsquery operator is inserted between surviving words.
59
+ *
60
+ * @param {string} query - The text to be converted into `tsquery`.
61
+ * @returns {SQL}
62
+ *
63
+ * @example
64
+ * ```ts
65
+ * await db.select().from(posts).where(sql`${to_tsvector(posts.title)} @@ ${plainto_tsquery('PostgreSQL MySQL SQLite')}`);
66
+ * ```
67
+ */
68
+ export declare function plainto_tsquery(query: string): SQL;
69
+ /**
70
+ * Converts a query to the `tsquery` data type.
71
+ *
72
+ * The text is parsed and normalized much as for `to_tsvector`, then the `&` (AND) tsquery operator is inserted between surviving words.
73
+ *
74
+ * @param {Configuration | string} configuration - Text search configuration (e.g., 'english', 'simple').
75
+ * @param {string} query - The text to be converted into `tsquery`.
76
+ * @returns {SQL}
77
+ *
78
+ * @example
79
+ * ```ts
80
+ * await db.select().from(posts).where(sql`${to_tsvector('english', posts.title)} @@ ${plainto_tsquery('english', 'PostgreSQL MySQL SQLite')}`);
81
+ * ```
82
+ */
83
+ export declare function plainto_tsquery(configuration: Configuration | string & {}, query: string): SQL;
84
+ /**
85
+ * Converts a query to the `tsquery` data type.
86
+ *
87
+ * `phraseto_tsquery` behaves much like `plainto_tsquery`, except that it inserts the `<->` (FOLLOWED BY) operator between surviving words instead of the `&` (AND) operator.
88
+ *
89
+ * @param {string} query - The text to be converted into `tsquery`.
90
+ * @returns {SQL}
91
+ *
92
+ * @example
93
+ * ```ts
94
+ * await db.select().from(posts).where(sql`${to_tsvector(posts.title)} @@ ${phraseto_tsquery('Drizzle best practice')}`);
95
+ * ```
96
+ */
97
+ export declare function phraseto_tsquery(query: string): SQL;
98
+ /**
99
+ * Converts a query to the `tsquery` data type.
100
+ *
101
+ * `phraseto_tsquery` behaves much like `plainto_tsquery`, except that it inserts the `<->` (FOLLOWED BY) operator between surviving words instead of the `&` (AND) operator.
102
+ *
103
+ * @param {Configuration | string} configuration - Text search configuration (e.g., 'english', 'simple').
104
+ * @param {string} query - The text to be converted into `tsquery`.
105
+ * @returns {SQL}
106
+ *
107
+ * @example
108
+ * ```ts
109
+ * await db.select().from(posts).where(sql`${to_tsvector('english', posts.title)} @@ ${phraseto_tsquery('english', 'Drizzle best practice')}`);
110
+ * ```
111
+ */
112
+ export declare function phraseto_tsquery(configuration: Configuration | string & {}, query: string): SQL;
113
+ /**
114
+ * Converts a query to the `tsquery` data type.
115
+ *
116
+ * `websearch_to_tsquery` creates a `tsquery` value from querytext using an alternative syntax in which simple unformatted text is a valid query. Unlike `plainto_tsquery` and `phraseto_tsquery`, it also recognizes certain operators. Moreover, this function will never raise syntax errors, which makes it possible to use raw user-supplied input for search.
117
+ *
118
+ * @param {string} query - The text to be converted into `tsquery`.
119
+ * @returns {SQL}
120
+ *
121
+ * @example
122
+ * ```ts
123
+ * await db.select().from(posts).where(sql`${to_tsvector(posts.title)} @@ ${websearch_to_tsquery('tips or updates Drizzle')}`);
124
+ * ```
125
+ */
126
+ export declare function websearch_to_tsquery(query: string): SQL;
127
+ /**
128
+ * Converts a query to the `tsquery` data type.
129
+ *
130
+ * `websearch_to_tsquery` creates a `tsquery` value from querytext using an alternative syntax in which simple unformatted text is a valid query. Unlike `plainto_tsquery` and `phraseto_tsquery`, it also recognizes certain operators. Moreover, this function will never raise syntax errors, which makes it possible to use raw user-supplied input for search.
131
+ *
132
+ * @param {Configuration | string} configuration - Text search configuration (e.g., 'english', 'simple').
133
+ * @param {string} query - The text to be converted into `tsquery`.
134
+ * @returns {SQL}
135
+ *
136
+ * @example
137
+ * ```ts
138
+ * await db.select().from(posts).where(sql`${to_tsvector('english', posts.title)} @@ ${websearch_to_tsquery('english', 'tips or updates Drizzle')}`);
139
+ * ```
140
+ */
141
+ export declare function websearch_to_tsquery(configuration: Configuration | string & {}, query: string): SQL;
142
+ /**
143
+ * Calculates the text search rank of a document represented by a `tsvector` against a `tsquery`.
144
+ *
145
+ * @param {SQL} vector - The `tsvector` representation of the document.
146
+ * @param {SQL} query - The `tsquery` to compare against the vector.
147
+ * @param {number} [normalization] - Optional normalization parameter. Specifies whether and how a document's length should impact its rank.
148
+ * @returns {SQL}
149
+ *
150
+ * @example
151
+ * ```ts
152
+ * const vector = to_tsvector('english', posts.title);
153
+ * const query = to_tsquery('english', 'Drizzle');
154
+ * const rank = ts_rank(vector, query);
155
+ *
156
+ * await db.select({ post: posts, rank }).from(posts).where(gt(rank, 0));
157
+ * ```
158
+ */
159
+ export declare function ts_rank(vector: SQL, query: SQL, normalization?: number): SQL;
160
+ /**
161
+ * Calculates the text search rank of a document represented by a `tsvector` against a `tsquery`, using weights.
162
+ *
163
+ * @param {number[]} weights - Array of weights applied to the document's components.
164
+ * @param {SQL} vector - The `tsvector` representation of the document.
165
+ * @param {SQL} query - The `tsquery` to compare against the vector.
166
+ * @param {number} [normalization] - Optional normalization parameter. Specifies whether and how a document's length should impact its rank.
167
+ * @returns {SQL}
168
+ *
169
+ * @example
170
+ * ```ts
171
+ * const weights = [0.1, 0.2, 0.4, 0.3];
172
+ * const vector = to_tsvector('english', posts.title);
173
+ * const query = to_tsquery('english', 'Drizzle');
174
+ * const rank = ts_rank(weights, vector, query);
175
+ *
176
+ * await db.select({ post: posts, rank }).from(posts).where(gt(rank, 0));
177
+ * ```
178
+ */
179
+ export declare function ts_rank(weights: number[], vector: SQL, query: SQL, normalization?: number): SQL;
180
+ /**
181
+ * Calculates the text search rank of a document with cover density ranking, represented by a `tsvector` against a `tsquery`.
182
+ *
183
+ * @param {SQL} vector - The `tsvector` representation of the document.
184
+ * @param {SQL} query - The `tsquery` to compare against the vector.
185
+ * @param {number} [normalization] - Optional normalization parameter. Specifies whether and how a document's length should impact its rank.
186
+ * @returns {SQL}
187
+ *
188
+ * @example
189
+ * ```ts
190
+ * const vector = to_tsvector('english', posts.title);
191
+ * const query = to_tsquery('english', 'Drizzle');
192
+ * const rankCd = ts_rank_cd(vector, query);
193
+ *
194
+ * await db.select({ post: posts, rankCd }).from(posts).where(gt(rankCd, 0));
195
+ * ```
196
+ */
197
+ export declare function ts_rank_cd(vector: SQL, query: SQL, normalization?: number): SQL;
198
+ /**
199
+ * Calculates the text search rank of a document represented by a `tsvector` against a `tsquery`, using weights.
200
+ *
201
+ * @param {number[]} weights - Array of weights applied to the document's components.
202
+ * @param {SQL} vector - The `tsvector` representation of the document.
203
+ * @param {SQL} query - The `tsquery` to compare against the vector.
204
+ * @param {number} [normalization] - Optional normalization parameter. Specifies whether and how a document's length should impact its rank.
205
+ * @returns {SQL}
206
+ *
207
+ * @example
208
+ * ```ts
209
+ * const weights = [0.1, 0.2, 0.4, 0.3];
210
+ * const vector = to_tsvector('english', posts.title);
211
+ * const query = to_tsquery('english', 'Drizzle');
212
+ * const rankCd = ts_rank_cd(weights, vector, query);
213
+ *
214
+ * await db.select({ post: posts, rankCd }).from(posts).where(gt(rankCd, 0));
215
+ * ```
216
+ */
217
+ export declare function ts_rank_cd(weights: number[], vector: SQL, query: SQL, normalization?: number): SQL;
218
+ /**
219
+ * Used to label the entries of a `tsvector` with a given weight, where a weight is one of the letters A, B, C, or D.
220
+ *
221
+ * @param {SQL} vector - The `tsvector` representation of the document.
222
+ * @param {Weight} weight - The weight to be assigned to the elements of the vector.
223
+ * @returns {SQL}
224
+ *
225
+ * @example
226
+ * ```ts
227
+ * const weightedVectorTitle = setweight(to_tsvector('english', posts.title), 'A');
228
+ * const weightedVectorDescription = setweight(to_tsvector('english', posts.description), 'B');
229
+ * const query = to_tsquery('english', 'Drizzle');
230
+ *
231
+ * await db.select().from(posts).where(sql`(${weightedVectorTitle} || ${weightedVectorDescription}) @@ ${query}`);
232
+ * ```
233
+ */
234
+ export declare function setweight(vector: SQL, weight: Weight | string & {}): SQL;
235
+ export {};