@supabase/postgrest-js 1.0.0-rc.5 → 1.0.0

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 (54) hide show
  1. package/dist/main/PostgrestBuilder.d.ts.map +1 -1
  2. package/dist/main/PostgrestBuilder.js +22 -23
  3. package/dist/main/PostgrestBuilder.js.map +1 -1
  4. package/dist/main/PostgrestClient.d.ts +33 -9
  5. package/dist/main/PostgrestClient.d.ts.map +1 -1
  6. package/dist/main/PostgrestClient.js +32 -6
  7. package/dist/main/PostgrestClient.js.map +1 -1
  8. package/dist/main/PostgrestFilterBuilder.d.ts +133 -114
  9. package/dist/main/PostgrestFilterBuilder.d.ts.map +1 -1
  10. package/dist/main/PostgrestFilterBuilder.js +30 -23
  11. package/dist/main/PostgrestFilterBuilder.js.map +1 -1
  12. package/dist/main/PostgrestQueryBuilder.d.ts +104 -19
  13. package/dist/main/PostgrestQueryBuilder.d.ts.map +1 -1
  14. package/dist/main/PostgrestQueryBuilder.js +103 -10
  15. package/dist/main/PostgrestQueryBuilder.js.map +1 -1
  16. package/dist/main/PostgrestTransformBuilder.d.ts +67 -33
  17. package/dist/main/PostgrestTransformBuilder.d.ts.map +1 -1
  18. package/dist/main/PostgrestTransformBuilder.js +53 -27
  19. package/dist/main/PostgrestTransformBuilder.js.map +1 -1
  20. package/dist/main/types.d.ts +7 -7
  21. package/dist/main/types.d.ts.map +1 -1
  22. package/dist/main/version.d.ts +1 -1
  23. package/dist/main/version.js +1 -1
  24. package/dist/module/PostgrestBuilder.d.ts.map +1 -1
  25. package/dist/module/PostgrestBuilder.js +22 -23
  26. package/dist/module/PostgrestBuilder.js.map +1 -1
  27. package/dist/module/PostgrestClient.d.ts +33 -9
  28. package/dist/module/PostgrestClient.d.ts.map +1 -1
  29. package/dist/module/PostgrestClient.js +32 -6
  30. package/dist/module/PostgrestClient.js.map +1 -1
  31. package/dist/module/PostgrestFilterBuilder.d.ts +133 -114
  32. package/dist/module/PostgrestFilterBuilder.d.ts.map +1 -1
  33. package/dist/module/PostgrestFilterBuilder.js +30 -23
  34. package/dist/module/PostgrestFilterBuilder.js.map +1 -1
  35. package/dist/module/PostgrestQueryBuilder.d.ts +104 -19
  36. package/dist/module/PostgrestQueryBuilder.d.ts.map +1 -1
  37. package/dist/module/PostgrestQueryBuilder.js +103 -10
  38. package/dist/module/PostgrestQueryBuilder.js.map +1 -1
  39. package/dist/module/PostgrestTransformBuilder.d.ts +67 -33
  40. package/dist/module/PostgrestTransformBuilder.d.ts.map +1 -1
  41. package/dist/module/PostgrestTransformBuilder.js +53 -27
  42. package/dist/module/PostgrestTransformBuilder.js.map +1 -1
  43. package/dist/module/types.d.ts +7 -7
  44. package/dist/module/types.d.ts.map +1 -1
  45. package/dist/module/version.d.ts +1 -1
  46. package/dist/module/version.js +1 -1
  47. package/package.json +8 -10
  48. package/src/PostgrestBuilder.ts +17 -18
  49. package/src/PostgrestClient.ts +33 -9
  50. package/src/PostgrestFilterBuilder.ts +158 -140
  51. package/src/PostgrestQueryBuilder.ts +104 -19
  52. package/src/PostgrestTransformBuilder.ts +67 -34
  53. package/src/types.ts +7 -7
  54. package/src/version.ts +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"PostgrestBuilder.d.ts","sourceRoot":"","sources":["../../src/PostgrestBuilder.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,KAAK,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAA;AAEvD,MAAM,CAAC,OAAO,CAAC,QAAQ,OAAO,gBAAgB,CAAC,MAAM,CACnD,YAAW,WAAW,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAC;IAEjD,SAAS,CAAC,MAAM,EAAE,KAAK,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,QAAQ,CAAA;IAC9D,SAAS,CAAC,GAAG,EAAE,GAAG,CAAA;IAClB,SAAS,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC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,EAAE,MAAM,CAAC,CAAA;IACzC,SAAS,CAAC,MAAM,CAAC,EAAE,MAAM,CAAA;IACzB,SAAS,CAAC,IAAI,CAAC,EAAE,OAAO,CAAA;IACxB,SAAS,CAAC,kBAAkB,UAAQ;IACpC,SAAS,CAAC,MAAM,CAAC,EAAE,WAAW,CAAA;IAC9B,SAAS,CAAC,KAAK,EAAE,KAAK,CAAA;IACtB,SAAS,CAAC,UAAU,EAAE,OAAO,CAAA;gBAEjB,OAAO,EAAE,gBAAgB,CAAC,MAAM,CAAC;IAmB7C;;;;;OAKG;IACH,YAAY,IAAI,IAAI;IAKpB,IAAI,CAAC,QAAQ,GAAG,iBAAiB,CAAC,MAAM,CAAC,EAAE,QAAQ,GAAG,KAAK,EACzD,WAAW,CAAC,EACR,CAAC,CAAC,KAAK,EAAE,iBAAiB,CAAC,MAAM,CAAC,KAAK,QAAQ,GAAG,WAAW,CAAC,QAAQ,CAAC,CAAC,GACxE,SAAS,GACT,IAAI,EACR,UAAU,CAAC,EAAE,CAAC,CAAC,MAAM,EAAE,GAAG,KAAK,QAAQ,GAAG,WAAW,CAAC,QAAQ,CAAC,CAAC,GAAG,SAAS,GAAG,IAAI,GAClF,WAAW,CAAC,QAAQ,GAAG,QAAQ,CAAC;CAmGpC"}
@@ -46,7 +46,7 @@ class PostgrestBuilder {
46
46
  }
47
47
  then(onfulfilled, onrejected) {
48
48
  // https://postgrest.org/en/stable/api.html#switching-schemas
49
- if (typeof this.schema === 'undefined') {
49
+ if (this.schema === undefined) {
50
50
  // skip
51
51
  }
52
52
  else if (['GET', 'HEAD'].includes(this.method)) {
@@ -67,32 +67,31 @@ class PostgrestBuilder {
67
67
  body: JSON.stringify(this.body),
68
68
  signal: this.signal,
69
69
  }).then((res) => __awaiter(this, void 0, void 0, function* () {
70
- var _a, _b, _c, _d;
71
- let error = undefined;
72
- let data = undefined;
73
- let count = undefined;
70
+ var _a, _b, _c;
71
+ let error = null;
72
+ let data = null;
73
+ let count = null;
74
74
  let status = res.status;
75
75
  let statusText = res.statusText;
76
76
  if (res.ok) {
77
- const isReturnMinimal = (_a = this.headers['Prefer']) === null || _a === void 0 ? void 0 : _a.split(',').includes('return=minimal');
78
- if (this.method !== 'HEAD' && !isReturnMinimal) {
79
- const text = yield res.text();
80
- if (!text) {
81
- // discard `text`
77
+ if (this.method !== 'HEAD') {
78
+ const body = yield res.text();
79
+ if (body === '') {
80
+ // Prefer: return=minimal
82
81
  }
83
82
  else if (this.headers['Accept'] === 'text/csv') {
84
- data = text;
83
+ data = body;
85
84
  }
86
85
  else if (this.headers['Accept'] &&
87
- this.headers['Accept'].indexOf('application/vnd.pgrst.plan+text') !== -1) {
88
- data = text;
86
+ this.headers['Accept'].includes('application/vnd.pgrst.plan+text')) {
87
+ data = body;
89
88
  }
90
89
  else {
91
- data = JSON.parse(text);
90
+ data = JSON.parse(body);
92
91
  }
93
92
  }
94
- const countHeader = (_b = this.headers['Prefer']) === null || _b === void 0 ? void 0 : _b.match(/count=(exact|planned|estimated)/);
95
- const contentRange = (_c = res.headers.get('content-range')) === null || _c === void 0 ? void 0 : _c.split('/');
93
+ const countHeader = (_a = this.headers['Prefer']) === null || _a === void 0 ? void 0 : _a.match(/count=(exact|planned|estimated)/);
94
+ const contentRange = (_b = res.headers.get('content-range')) === null || _b === void 0 ? void 0 : _b.split('/');
96
95
  if (countHeader && contentRange && contentRange.length > 1) {
97
96
  count = parseInt(contentRange[1]);
98
97
  }
@@ -102,13 +101,13 @@ class PostgrestBuilder {
102
101
  try {
103
102
  error = JSON.parse(body);
104
103
  }
105
- catch (_e) {
104
+ catch (_d) {
106
105
  error = {
107
106
  message: body,
108
107
  };
109
108
  }
110
- if (error && this.allowEmpty && ((_d = error === null || error === void 0 ? void 0 : error.details) === null || _d === void 0 ? void 0 : _d.includes('Results contain 0 rows'))) {
111
- error = undefined;
109
+ if (error && this.allowEmpty && ((_c = error === null || error === void 0 ? void 0 : error.details) === null || _c === void 0 ? void 0 : _c.includes('Results contain 0 rows'))) {
110
+ error = null;
112
111
  status = 200;
113
112
  statusText = 'OK';
114
113
  }
@@ -133,10 +132,10 @@ class PostgrestBuilder {
133
132
  hint: '',
134
133
  code: fetchError.code || '',
135
134
  },
136
- data: undefined,
137
- count: undefined,
138
- status: 400,
139
- statusText: 'Bad Request',
135
+ data: null,
136
+ count: null,
137
+ status: 0,
138
+ statusText: '',
140
139
  }));
141
140
  }
142
141
  return res.then(onfulfilled, onrejected);
@@ -1 +1 @@
1
- {"version":3,"file":"PostgrestBuilder.js","sourceRoot":"","sources":["../../src/PostgrestBuilder.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,8DAAoC;AAIpC,MAA8B,gBAAgB;IAa5C,YAAY,OAAiC;QALnC,uBAAkB,GAAG,KAAK,CAAA;QAMlC,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAA;QAC5B,IAAI,CAAC,GAAG,GAAG,OAAO,CAAC,GAAG,CAAA;QACtB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAA;QAC9B,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAA;QAC5B,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,CAAA;QACxB,IAAI,CAAC,kBAAkB,GAAG,OAAO,CAAC,kBAAkB,CAAA;QACpD,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAA;QAC5B,IAAI,CAAC,UAAU,GAAG,OAAO,CAAC,UAAU,CAAA;QAEpC,IAAI,OAAO,CAAC,KAAK,EAAE;YACjB,IAAI,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,CAAA;SAC3B;aAAM,IAAI,OAAO,KAAK,KAAK,WAAW,EAAE;YACvC,IAAI,CAAC,KAAK,GAAG,qBAAU,CAAA;SACxB;aAAM;YACL,IAAI,CAAC,KAAK,GAAG,KAAK,CAAA;SACnB;IACH,CAAC;IAED;;;;;OAKG;IACH,YAAY;QACV,IAAI,CAAC,kBAAkB,G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AU,EAAE,EAAE,CAAC,CAAC;gBAC/B,KAAK,EAAE;oBACL,OAAO,EAAE,eAAe,UAAU,CAAC,OAAO,EAAE;oBAC5C,OAAO,EAAE,EAAE;oBACX,IAAI,EAAE,EAAE;oBACR,IAAI,EAAE,UAAU,CAAC,IAAI,IAAI,EAAE;iBAC5B;gBACD,IAAI,EAAE,IAAI;gBACV,KAAK,EAAE,IAAI;gBACX,MAAM,EAAE,CAAC;gBACT,UAAU,EAAE,EAAE;aACf,CAAC,CAAC,CAAA;SACJ;QAED,OAAO,GAAG,CAAC,IAAI,CAAC,WAAW,EAAE,UAAU,CAAC,CAAA;IAC1C,CAAC;CACF;AApJD,mCAoJC"}
@@ -1,6 +1,16 @@
1
1
  import PostgrestQueryBuilder from './PostgrestQueryBuilder';
2
2
  import PostgrestFilterBuilder from './PostgrestFilterBuilder';
3
3
  import { Fetch, GenericSchema } from './types';
4
+ /**
5
+ * PostgREST client.
6
+ *
7
+ * @typeParam Database - Types for the schema from the [type
8
+ * generator](https://supabase.com/docs/reference/javascript/next/typescript-support)
9
+ *
10
+ * @typeParam SchemaName - Postgres schema to switch to. Must be a string
11
+ * literal, the same one passed to the constructor. If the schema is not
12
+ * `"public"`, this must be supplied manually.
13
+ */
4
14
  export default class PostgrestClient<Database = any, SchemaName extends string & keyof Database = 'public' extends keyof Database ? 'public' : string & keyof Database, Schema extends GenericSchema = Database[SchemaName] extends GenericSchema ? Database[SchemaName] : any> {
5
15
  url: string;
6
16
  headers: Record<string, string>;
@@ -9,9 +19,11 @@ export default class PostgrestClient<Database = any, SchemaName extends string &
9
19
  /**
10
20
  * Creates a PostgREST client.
11
21
  *
12
- * @param url URL of the PostgREST endpoint.
13
- * @param headers Custom headers.
14
- * @param schema Postgres schema to switch to.
22
+ * @param url - URL of the PostgREST endpoint
23
+ * @param options - Named parameters
24
+ * @param options.headers - Custom headers
25
+ * @param options.schema - Postgres schema to switch to
26
+ * @param options.fetch - Custom fetch
15
27
  */
16
28
  constructor(url: string, { headers, schema, fetch, }?: {
17
29
  headers?: Record<string, string>;
@@ -21,7 +33,7 @@ export default class PostgrestClient<Database = any, SchemaName extends string &
21
33
  /**
22
34
  * Perform a query on a table or a view.
23
35
  *
24
- * @param relation The table or view name to query.
36
+ * @param relation - The table or view name to query
25
37
  */
26
38
  from<TableName extends string & keyof Schema['Tables'], Table extends Schema['Tables'][TableName]>(relation: TableName): PostgrestQueryBuilder<Table>;
27
39
  from<ViewName extends string & keyof Schema['Views'], View extends Schema['Views'][ViewName]>(relation: ViewName): PostgrestQueryBuilder<View>;
@@ -29,14 +41,26 @@ export default class PostgrestClient<Database = any, SchemaName extends string &
29
41
  /**
30
42
  * Perform a function call.
31
43
  *
32
- * @param fn The function name to call.
33
- * @param args The parameters to pass to the function call.
34
- * @param options Named parameters.
44
+ * @param fn - The function name to call
45
+ * @param args - The arguments to pass to the function call
46
+ * @param options - Named parameters
47
+ * @param options.head - When set to `true`, `data` will not be returned.
48
+ * Useful if you only need the count.
49
+ * @param options.count - Count algorithm to use to count rows returned by the
50
+ * function. Only applicable for [set-returning
51
+ * functions](https://www.postgresql.org/docs/current/functions-srf.html).
52
+ *
53
+ * `"exact"`: Exact but slow count algorithm. Performs a `COUNT(*)` under the
54
+ * hood.
55
+ *
56
+ * `"planned"`: Approximated but fast count algorithm. Uses the Postgres
57
+ * statistics under the hood.
58
+ *
59
+ * `"estimated"`: Uses exact count for low numbers and planned count for high
60
+ * numbers.
35
61
  */
36
62
  rpc<FunctionName extends string & keyof Schema['Functions'], Function_ extends Schema['Functions'][FunctionName]>(fn: FunctionName, args?: Function_['Args'], { head, count, }?: {
37
- /** When set to true, no data will be returned. */
38
63
  head?: boolean;
39
- /** Count algorithm to use to count rows in a table. */
40
64
  count?: 'exact' | 'planned' | 'estimated';
41
65
  }): PostgrestFilterBuilder<Function_['Returns'] extends any[] ? Function_['Returns'][number] extends Record<string, unknown> ? Function_['Returns'][number] : never : never, Function_['Returns']>;
42
66
  }
@@ -1 +1 @@
1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Y,EACZ,KAAK,GACN,GAAE;QACD,IAAI,CAAC,EAAE,OAAO,CAAA;QACd,KAAK,CAAC,EAAE,OAAO,GAAG,SAAS,GAAG,WAAW,CAAA;KACrC,GACL,sBAAsB,CACvB,SAAS,CAAC,SAAS,CAAC,SAAS,GAAG,EAAE,GAC9B,SAAS,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC1D,SAAS,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,GAC5B,KAAK,GACP,KAAK,EACT,SAAS,CAAC,SAAS,CAAC,CACrB;CA6BF"}
@@ -6,14 +6,26 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const PostgrestQueryBuilder_1 = __importDefault(require("./PostgrestQueryBuilder"));
7
7
  const PostgrestFilterBuilder_1 = __importDefault(require("./PostgrestFilterBuilder"));
8
8
  const constants_1 = require("./constants");
9
+ /**
10
+ * PostgREST client.
11
+ *
12
+ * @typeParam Database - Types for the schema from the [type
13
+ * generator](https://supabase.com/docs/reference/javascript/next/typescript-support)
14
+ *
15
+ * @typeParam SchemaName - Postgres schema to switch to. Must be a string
16
+ * literal, the same one passed to the constructor. If the schema is not
17
+ * `"public"`, this must be supplied manually.
18
+ */
9
19
  class PostgrestClient {
10
20
  // TODO: Add back shouldThrowOnError once we figure out the typings
11
21
  /**
12
22
  * Creates a PostgREST client.
13
23
  *
14
- * @param url URL of the PostgREST endpoint.
15
- * @param headers Custom headers.
16
- * @param schema Postgres schema to switch to.
24
+ * @param url - URL of the PostgREST endpoint
25
+ * @param options - Named parameters
26
+ * @param options.headers - Custom headers
27
+ * @param options.schema - Postgres schema to switch to
28
+ * @param options.fetch - Custom fetch
17
29
  */
18
30
  constructor(url, { headers = {}, schema, fetch, } = {}) {
19
31
  this.url = url;
@@ -32,9 +44,23 @@ class PostgrestClient {
32
44
  /**
33
45
  * Perform a function call.
34
46
  *
35
- * @param fn The function name to call.
36
- * @param args The parameters to pass to the function call.
37
- * @param options Named parameters.
47
+ * @param fn - The function name to call
48
+ * @param args - The arguments to pass to the function call
49
+ * @param options - Named parameters
50
+ * @param options.head - When set to `true`, `data` will not be returned.
51
+ * Useful if you only need the count.
52
+ * @param options.count - Count algorithm to use to count rows returned by the
53
+ * function. Only applicable for [set-returning
54
+ * functions](https://www.postgresql.org/docs/current/functions-srf.html).
55
+ *
56
+ * `"exact"`: Exact but slow count algorithm. Performs a `COUNT(*)` under the
57
+ * hood.
58
+ *
59
+ * `"planned"`: Approximated but fast count algorithm. Uses the Postgres
60
+ * statistics under the hood.
61
+ *
62
+ * `"estimated"`: Uses exact count for low numbers and planned count for high
63
+ * numbers.
38
64
  */
39
65
  rpc(fn, args = {}, { head = false, count, } = {}) {
40
66
  let method;
@@ -1 +1 @@
1
- {"version":3,"file":"PostgrestClient.js","sourceRoot":"","sources":["../../src/PostgrestClient.ts"],"names":[],"mappings":";;;;;AAAA,oFAA2D;AAC3D,sFAA6D;AAE7D,2CAA6C;AAG7C,MAAqB,eAAe;IAclC,mEAAmE;IACnE;;;;;;OAMG;IACH,YACE,GAAW,EACX,EACE,OAAO,GAAG,EAAE,EACZ,MAAM,EACN,KAAK,MAKH,EAAE;QAEN,IAAI,CAAC,GAAG,GAAG,GAAG,CAAA;QACd,IAAI,CAAC,OAAO,mCAAQ,2BAAe,GAAK,OAAO,CAAE,CAAA;QACjD,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;QACpB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAA;IACpB,CAAC;IAeD,IAAI,CAAC,QAAgB;QACnB,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,GAAG,IAAI,CAAC,GAAG,IAAI,QAAQ,EAAE,CAAC,CAAA;QAC9C,OAAO,IAAI,+BAAqB,CAAM,GAAG,EAAE;YACzC,OAAO,oBAAO,IAAI,CAAC,OAAO,CAAE;YAC5B,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,KAAK,EAAE,IAAI,CA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AAQ,IAAI,CAAC,OAAO,CAAE,CAAA;QACnC,IAAI,KAAK,EAAE;YACT,OAAO,CAAC,QAAQ,CAAC,GAAG,SAAS,KAAK,EAAE,CAAA;SACrC;QAED,OAAO,IAAI,gCAAsB,CAAC;YAChC,MAAM;YACN,GAAG;YACH,OAAO;YACP,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,IAAI;YACJ,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,UAAU,EAAE,KAAK;SACmC,CAAC,CAAA;IACzD,CAAC;CACF;AAtID,kCAsIC"}
@@ -1,197 +1,178 @@
1
1
  import PostgrestTransformBuilder from './PostgrestTransformBuilder';
2
- /**
3
- * Filters
4
- */
5
2
  declare type FilterOperator = 'eq' | 'neq' | 'gt' | 'gte' | 'lt' | 'lte' | 'like' | 'ilike' | 'is' | 'in' | 'cs' | 'cd' | 'sl' | 'sr' | 'nxl' | 'nxr' | 'adj' | 'ov' | 'fts' | 'plfts' | 'phfts' | 'wfts';
6
3
  export default class PostgrestFilterBuilder<Row extends Record<string, unknown>, Result> extends PostgrestTransformBuilder<Row, Result> {
7
4
  /**
8
- * Finds all rows which doesn't satisfy the filter.
5
+ * Match only rows where `column` is equal to `value`.
9
6
  *
10
- * @param column The column to filter on.
11
- * @param operator The operator to filter with.
12
- * @param value The value to filter with.
13
- */
14
- not<ColumnName extends string & keyof Row>(column: ColumnName, operator: FilterOperator, value: Row[ColumnName]): this;
15
- not(column: string, operator: string, value: unknown): this;
16
- /**
17
- * Finds all rows satisfying at least one of the filters.
18
- *
19
- * @param filters The filters to use, separated by commas.
20
- * @param foreignTable The foreign table to use (if `column` is a foreign column).
21
- */
22
- or(filters: string, { foreignTable }?: {
23
- foreignTable?: string;
24
- }): this;
25
- /**
26
- * Finds all rows whose value on the stated `column` exactly matches the
27
- * specified `value`.
7
+ * To check if the value of `column` is NULL, you should use `.is()` instead.
28
8
  *
29
- * @param column The column to filter on.
30
- * @param value The value to filter with.
9
+ * @param column - The column to filter on
10
+ * @param value - The value to filter with
31
11
  */
32
12
  eq<ColumnName extends string & keyof Row>(column: ColumnName, value: Row[ColumnName]): this;
33
13
  eq(column: string, value: unknown): this;
34
14
  /**
35
- * Finds all rows whose value on the stated `column` doesn't match the
36
- * specified `value`.
15
+ * Match only rows where `column` is not equal to `value`.
37
16
  *
38
- * @param column The column to filter on.
39
- * @param value The value to filter with.
17
+ * @param column - The column to filter on
18
+ * @param value - The value to filter with
40
19
  */
41
20
  neq<ColumnName extends string & keyof Row>(column: ColumnName, value: Row[ColumnName]): this;
42
21
  neq(column: string, value: unknown): this;
43
22
  /**
44
- * Finds all rows whose value on the stated `column` is greater than the
45
- * specified `value`.
23
+ * Match only rows where `column` is greater than `value`.
46
24
  *
47
- * @param column The column to filter on.
48
- * @param value The value to filter with.
25
+ * @param column - The column to filter on
26
+ * @param value - The value to filter with
49
27
  */
50
28
  gt<ColumnName extends string & keyof Row>(column: ColumnName, value: Row[ColumnName]): this;
51
29
  gt(column: string, value: unknown): this;
52
30
  /**
53
- * Finds all rows whose value on the stated `column` is greater than or
54
- * equal to the specified `value`.
31
+ * Match only rows where `column` is greater than or equal to `value`.
55
32
  *
56
- * @param column The column to filter on.
57
- * @param value The value to filter with.
33
+ * @param column - The column to filter on
34
+ * @param value - The value to filter with
58
35
  */
59
36
  gte<ColumnName extends string & keyof Row>(column: ColumnName, value: Row[ColumnName]): this;
60
37
  gte(column: string, value: unknown): this;
61
38
  /**
62
- * Finds all rows whose value on the stated `column` is less than the
63
- * specified `value`.
39
+ * Match only rows where `column` is less than `value`.
64
40
  *
65
- * @param column The column to filter on.
66
- * @param value The value to filter with.
41
+ * @param column - The column to filter on
42
+ * @param value - The value to filter with
67
43
  */
68
44
  lt<ColumnName extends string & keyof Row>(column: ColumnName, value: Row[ColumnName]): this;
69
45
  lt(column: string, value: unknown): this;
70
46
  /**
71
- * Finds all rows whose value on the stated `column` is less than or equal
72
- * to the specified `value`.
47
+ * Match only rows where `column` is less than or equal to `value`.
73
48
  *
74
- * @param column The column to filter on.
75
- * @param value The value to filter with.
49
+ * @param column - The column to filter on
50
+ * @param value - The value to filter with
76
51
  */
77
52
  lte<ColumnName extends string & keyof Row>(column: ColumnName, value: Row[ColumnName]): this;
78
53
  lte(column: string, value: unknown): this;
79
54
  /**
80
- * Finds all rows whose value in the stated `column` matches the supplied
81
- * `pattern` (case sensitive).
55
+ * Match only rows where `column` matches `pattern` case-sensitively.
82
56
  *
83
- * @param column The column to filter on.
84
- * @param pattern The pattern to filter with.
57
+ * @param column - The column to filter on
58
+ * @param pattern - The pattern to match with
85
59
  */
86
60
  like<ColumnName extends string & keyof Row>(column: ColumnName, pattern: string): this;
87
61
  like(column: string, pattern: string): this;
88
62
  /**
89
- * Finds all rows whose value in the stated `column` matches the supplied
90
- * `pattern` (case insensitive).
63
+ * Match only rows where `column` matches `pattern` case-insensitively.
91
64
  *
92
- * @param column The column to filter on.
93
- * @param pattern The pattern to filter with.
65
+ * @param column - The column to filter on
66
+ * @param pattern - The pattern to match with
94
67
  */
95
68
  ilike<ColumnName extends string & keyof Row>(column: ColumnName, pattern: string): this;
96
69
  ilike(column: string, pattern: string): this;
97
70
  /**
98
- * A check for exact equality (null, true, false), finds all rows whose
99
- * value on the stated `column` exactly match the specified `value`.
71
+ * Match only rows where `column` IS `value`.
72
+ *
73
+ * For non-boolean columns, this is only relevant for checking if the value of
74
+ * `column` is NULL by setting `value` to `null`.
75
+ *
76
+ * For boolean columns, you can also set `value` to `true` or `false` and it
77
+ * will behave the same way as `.eq()`.
100
78
  *
101
- * @param column The column to filter on.
102
- * @param value The value to filter with.
79
+ * @param column - The column to filter on
80
+ * @param value - The value to filter with
103
81
  */
104
82
  is<ColumnName extends string & keyof Row>(column: ColumnName, value: Row[ColumnName] & (boolean | null)): this;
105
83
  is(column: string, value: boolean | null): this;
106
84
  /**
107
- * Finds all rows whose value on the stated `column` is found on the
108
- * specified `values`.
85
+ * Match only rows where `column` is included in the `values` array.
109
86
  *
110
- * @param column The column to filter on.
111
- * @param values The values to filter with.
87
+ * @param column - The column to filter on
88
+ * @param values - The values array to filter with
112
89
  */
113
90
  in<ColumnName extends string & keyof Row>(column: ColumnName, values: Row[ColumnName][]): this;
114
91
  in(column: string, values: unknown[]): this;
115
92
  /**
116
- * Finds all rows whose json, array, or range value on the stated `column`
117
- * contains the values specified in `value`.
93
+ * Only relevant for jsonb, array, and range columns. Match only rows where
94
+ * `column` contains every element appearing in `value`.
118
95
  *
119
- * @param column The column to filter on.
120
- * @param value The value to filter with.
96
+ * @param column - The jsonb, array, or range column to filter on
97
+ * @param value - The jsonb, array, or range value to filter with
121
98
  */
122
99
  contains<ColumnName extends string & keyof Row>(column: ColumnName, value: string | Row[ColumnName][] | Record<string, unknown>): this;
123
100
  contains(column: string, value: string | unknown[] | Record<string, unknown>): this;
124
101
  /**
125
- * Finds all rows whose json, array, or range value on the stated `column` is
126
- * contained by the specified `value`.
102
+ * Only relevant for jsonb, array, and range columns. Match only rows where
103
+ * every element appearing in `column` is contained by `value`.
127
104
  *
128
- * @param column The column to filter on.
129
- * @param value The value to filter with.
105
+ * @param column - The jsonb, array, or range column to filter on
106
+ * @param value - The jsonb, array, or range value to filter with
130
107
  */
131
108
  containedBy<ColumnName extends string & keyof Row>(column: ColumnName, value: string | Row[ColumnName][] | Record<string, unknown>): this;
132
109
  containedBy(column: string, value: string | unknown[] | Record<string, unknown>): this;
133
110
  /**
134
- * Finds all rows whose range value on the stated `column` is strictly to the
135
- * left of the specified `range`.
111
+ * Only relevant for range columns. Match only rows where every element in
112
+ * `column` is greater than any element in `range`.
136
113
  *
137
- * @param column The column to filter on.
138
- * @param range The range to filter with.
139
- */
140
- rangeLt<ColumnName extends string & keyof Row>(column: ColumnName, range: string): this;
141
- rangeLt(column: string, range: string): this;
142
- /**
143
- * Finds all rows whose range value on the stated `column` is strictly to
144
- * the right of the specified `range`.
145
- *
146
- * @param column The column to filter on.
147
- * @param range The range to filter with.
114
+ * @param column - The range column to filter on
115
+ * @param range - The range to filter with
148
116
  */
149
117
  rangeGt<ColumnName extends string & keyof Row>(column: ColumnName, range: string): this;
150
118
  rangeGt(column: string, range: string): this;
151
119
  /**
152
- * Finds all rows whose range value on the stated `column` does not extend
153
- * to the left of the specified `range`.
120
+ * Only relevant for range columns. Match only rows where every element in
121
+ * `column` is either contained in `range` or greater than any element in
122
+ * `range`.
154
123
  *
155
- * @param column The column to filter on.
156
- * @param range The range to filter with.
124
+ * @param column - The range column to filter on
125
+ * @param range - The range to filter with
157
126
  */
158
127
  rangeGte<ColumnName extends string & keyof Row>(column: ColumnName, range: string): this;
159
128
  rangeGte(column: string, range: string): this;
160
129
  /**
161
- * Finds all rows whose range value on the stated `column` does not extend
162
- * to the right of the specified `range`.
130
+ * Only relevant for range columns. Match only rows where every element in
131
+ * `column` is less than any element in `range`.
163
132
  *
164
- * @param column The column to filter on.
165
- * @param range The range to filter with.
133
+ * @param column - The range column to filter on
134
+ * @param range - The range to filter with
135
+ */
136
+ rangeLt<ColumnName extends string & keyof Row>(column: ColumnName, range: string): this;
137
+ rangeLt(column: string, range: string): this;
138
+ /**
139
+ * Only relevant for range columns. Match only rows where every element in
140
+ * `column` is either contained in `range` or less than any element in
141
+ * `range`.
142
+ *
143
+ * @param column - The range column to filter on
144
+ * @param range - The range to filter with
166
145
  */
167
146
  rangeLte<ColumnName extends string & keyof Row>(column: ColumnName, range: string): this;
168
147
  rangeLte(column: string, range: string): this;
169
148
  /**
170
- * Finds all rows whose range value on the stated `column` is adjacent to
171
- * the specified `range`.
149
+ * Only relevant for range columns. Match only rows where `column` is
150
+ * mutually exclusive to `range` and there can be no element between the two
151
+ * ranges.
172
152
  *
173
- * @param column The column to filter on.
174
- * @param range The range to filter with.
153
+ * @param column - The range column to filter on
154
+ * @param range - The range to filter with
175
155
  */
176
156
  rangeAdjacent<ColumnName extends string & keyof Row>(column: ColumnName, range: string): this;
177
157
  rangeAdjacent(column: string, range: string): this;
178
158
  /**
179
- * Finds all rows whose array or range value on the stated `column` overlaps
180
- * (has a value in common) with the specified `value`.
159
+ * Only relevant for array and range columns. Match only rows where
160
+ * `column` and `value` have an element in common.
181
161
  *
182
- * @param column The column to filter on.
183
- * @param value The value to filter with.
162
+ * @param column - The array or range column to filter on
163
+ * @param value - The array or range value to filter with
184
164
  */
185
165
  overlaps<ColumnName extends string & keyof Row>(column: ColumnName, value: string | Row[ColumnName][]): this;
186
166
  overlaps(column: string, value: string | unknown[]): this;
187
167
  /**
188
- * Finds all rows whose text or tsvector value on the stated `column` matches
189
- * the tsquery in `query`.
168
+ * Only relevant for text and tsvector columns. Match only rows where
169
+ * `column` matches the query string in `query`.
190
170
  *
191
- * @param column The column to filter on.
192
- * @param query The Postgres tsquery string to filter with.
193
- * @param config The text search configuration to use.
194
- * @param type The type of tsquery conversion to use on `query`.
171
+ * @param column - The text or tsvector column to filter on
172
+ * @param query - The query text to match with
173
+ * @param options - Named parameters
174
+ * @param options.config - The text search configuration to use
175
+ * @param options.type - Change how the `query` text is interpreted
195
176
  */
196
177
  textSearch<ColumnName extends string & keyof Row>(column: ColumnName, query: string, options?: {
197
178
  config?: string;
@@ -202,22 +183,60 @@ export default class PostgrestFilterBuilder<Row extends Record<string, unknown>,
202
183
  type?: 'plain' | 'phrase' | 'websearch';
203
184
  }): this;
204
185
  /**
205
- * Finds all rows whose `column` satisfies the filter.
186
+ * Match only rows where each column in `query` keys is equal to its
187
+ * associated value. Shorthand for multiple `.eq()`s.
206
188
  *
207
- * @param column The column to filter on.
208
- * @param operator The operator to filter with.
209
- * @param value The value to filter with.
189
+ * @param query - The object to filter with, with column names as keys mapped
190
+ * to their filter values
210
191
  */
211
- filter<ColumnName extends string & keyof Row>(column: ColumnName, operator: `${'' | 'not.'}${FilterOperator}`, value: unknown): this;
212
- filter(column: string, operator: string, value: unknown): this;
192
+ match<ColumnName extends string & keyof Row>(query: Record<ColumnName, Row[ColumnName]>): this;
193
+ match(query: Record<string, unknown>): this;
213
194
  /**
214
- * Finds all rows whose columns match the specified `query` object.
195
+ * Match only rows which doesn't satisfy the filter.
215
196
  *
216
- * @param query The object to filter with, with column names as keys mapped
217
- * to their filter values.
197
+ * Unlike most filters, `opearator` and `value` are used as-is and need to
198
+ * follow [PostgREST
199
+ * syntax](https://postgrest.org/en/stable/api.html#operators). You also need
200
+ * to make sure they are properly sanitized.
201
+ *
202
+ * @param column - The column to filter on
203
+ * @param operator - The operator to be negated to filter with, following
204
+ * PostgREST syntax
205
+ * @param value - The value to filter with, following PostgREST syntax
218
206
  */
219
- match<ColumnName extends string & keyof Row>(query: Record<ColumnName, Row[ColumnName]>): this;
220
- match(query: Record<string, unknown>): this;
207
+ not<ColumnName extends string & keyof Row>(column: ColumnName, operator: FilterOperator, value: Row[ColumnName]): this;
208
+ not(column: string, operator: string, value: unknown): this;
209
+ /**
210
+ * Match only rows which satisfy at least one of the filters.
211
+ *
212
+ * Unlike most filters, `filters` is used as-is and needs to follow [PostgREST
213
+ * syntax](https://postgrest.org/en/stable/api.html#operators). You also need
214
+ * to make sure it's properly sanitized.
215
+ *
216
+ * It's currently not possible to do an `.or()` filter across multiple tables.
217
+ *
218
+ * @param filters - The filters to use, following PostgREST syntax
219
+ * @param foreignTable - Set this to filter on foreign tables instead of the
220
+ * current table
221
+ */
222
+ or(filters: string, { foreignTable }?: {
223
+ foreignTable?: string;
224
+ }): this;
225
+ /**
226
+ * Match only rows which satisfy the filter. This is an escape hatch - you
227
+ * should use the specific filter methods wherever possible.
228
+ *
229
+ * Unlike most filters, `opearator` and `value` are used as-is and need to
230
+ * follow [PostgREST
231
+ * syntax](https://postgrest.org/en/stable/api.html#operators). You also need
232
+ * to make sure they are properly sanitized.
233
+ *
234
+ * @param column - The column to filter on
235
+ * @param operator - The operator to filter with, following PostgREST syntax
236
+ * @param value - The value to filter with, following PostgREST syntax
237
+ */
238
+ filter<ColumnName extends string & keyof Row>(column: ColumnName, operator: `${'' | 'not.'}${FilterOperator}`, value: unknown): this;
239
+ filter(column: string, operator: string, value: unknown): this;
221
240
  }
222
241
  export {};
223
242
  //# sourceMappingURL=PostgrestFilterBuilder.d.ts.map