@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.
- package/dist/main/PostgrestBuilder.d.ts.map +1 -1
- package/dist/main/PostgrestBuilder.js +22 -23
- package/dist/main/PostgrestBuilder.js.map +1 -1
- package/dist/main/PostgrestClient.d.ts +33 -9
- package/dist/main/PostgrestClient.d.ts.map +1 -1
- package/dist/main/PostgrestClient.js +32 -6
- package/dist/main/PostgrestClient.js.map +1 -1
- package/dist/main/PostgrestFilterBuilder.d.ts +133 -114
- package/dist/main/PostgrestFilterBuilder.d.ts.map +1 -1
- package/dist/main/PostgrestFilterBuilder.js +30 -23
- package/dist/main/PostgrestFilterBuilder.js.map +1 -1
- package/dist/main/PostgrestQueryBuilder.d.ts +104 -19
- package/dist/main/PostgrestQueryBuilder.d.ts.map +1 -1
- package/dist/main/PostgrestQueryBuilder.js +103 -10
- package/dist/main/PostgrestQueryBuilder.js.map +1 -1
- package/dist/main/PostgrestTransformBuilder.d.ts +67 -33
- package/dist/main/PostgrestTransformBuilder.d.ts.map +1 -1
- package/dist/main/PostgrestTransformBuilder.js +53 -27
- package/dist/main/PostgrestTransformBuilder.js.map +1 -1
- package/dist/main/types.d.ts +7 -7
- package/dist/main/types.d.ts.map +1 -1
- package/dist/main/version.d.ts +1 -1
- package/dist/main/version.js +1 -1
- package/dist/module/PostgrestBuilder.d.ts.map +1 -1
- package/dist/module/PostgrestBuilder.js +22 -23
- package/dist/module/PostgrestBuilder.js.map +1 -1
- package/dist/module/PostgrestClient.d.ts +33 -9
- package/dist/module/PostgrestClient.d.ts.map +1 -1
- package/dist/module/PostgrestClient.js +32 -6
- package/dist/module/PostgrestClient.js.map +1 -1
- package/dist/module/PostgrestFilterBuilder.d.ts +133 -114
- package/dist/module/PostgrestFilterBuilder.d.ts.map +1 -1
- package/dist/module/PostgrestFilterBuilder.js +30 -23
- package/dist/module/PostgrestFilterBuilder.js.map +1 -1
- package/dist/module/PostgrestQueryBuilder.d.ts +104 -19
- package/dist/module/PostgrestQueryBuilder.d.ts.map +1 -1
- package/dist/module/PostgrestQueryBuilder.js +103 -10
- package/dist/module/PostgrestQueryBuilder.js.map +1 -1
- package/dist/module/PostgrestTransformBuilder.d.ts +67 -33
- package/dist/module/PostgrestTransformBuilder.d.ts.map +1 -1
- package/dist/module/PostgrestTransformBuilder.js +53 -27
- package/dist/module/PostgrestTransformBuilder.js.map +1 -1
- package/dist/module/types.d.ts +7 -7
- package/dist/module/types.d.ts.map +1 -1
- package/dist/module/version.d.ts +1 -1
- package/dist/module/version.js +1 -1
- package/package.json +8 -10
- package/src/PostgrestBuilder.ts +17 -18
- package/src/PostgrestClient.ts +33 -9
- package/src/PostgrestFilterBuilder.ts +158 -140
- package/src/PostgrestQueryBuilder.ts +104 -19
- package/src/PostgrestTransformBuilder.ts +67 -34
- package/src/types.ts +7 -7
- 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,CAAA;IACzC,SAAS,CAAC,MAAM,CAAC,EAAE,MAAM,CAAA;IACzB,SAAS,CAAC,IAAI,CAAC,EAAE,OAAO,CAAA;IACxB,SAAS,CAAC,kBAAkB,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,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 (
|
|
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
|
|
71
|
-
let error =
|
|
72
|
-
let data =
|
|
73
|
-
let count =
|
|
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
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
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 =
|
|
83
|
+
data = body;
|
|
85
84
|
}
|
|
86
85
|
else if (this.headers['Accept'] &&
|
|
87
|
-
this.headers['Accept'].
|
|
88
|
-
data =
|
|
86
|
+
this.headers['Accept'].includes('application/vnd.pgrst.plan+text')) {
|
|
87
|
+
data = body;
|
|
89
88
|
}
|
|
90
89
|
else {
|
|
91
|
-
data = JSON.parse(
|
|
90
|
+
data = JSON.parse(body);
|
|
92
91
|
}
|
|
93
92
|
}
|
|
94
|
-
const countHeader = (
|
|
95
|
-
const contentRange = (
|
|
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 (
|
|
104
|
+
catch (_d) {
|
|
106
105
|
error = {
|
|
107
106
|
message: body,
|
|
108
107
|
};
|
|
109
108
|
}
|
|
110
|
-
if (error && this.allowEmpty && ((
|
|
111
|
-
error =
|
|
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:
|
|
137
|
-
count:
|
|
138
|
-
status:
|
|
139
|
-
statusText: '
|
|
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,GA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AAA;oBACZ,UAAU,GAAG,IAAI,CAAA;iBAClB;gBAED,IAAI,KAAK,IAAI,IAAI,CAAC,kBAAkB,EAAE;oBACpC,MAAM,KAAK,CAAA;iBACZ;aACF;YAED,MAAM,iBAAiB,GAAG;gBACxB,KAAK;gBACL,IAAI;gBACJ,KAAK;gBACL,MAAM;gBACN,UAAU;aACX,CAAA;YAED,OAAO,iBAAiB,CAAA;QAC1B,CAAC,CAAA,CAAC,CAAA;QACF,IAAI,CAAC,IAAI,CAAC,kBAAkB,EAAE;YAC5B,GAAG,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,UAAU,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
|
|
13
|
-
* @param
|
|
14
|
-
* @param
|
|
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
|
|
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
|
|
33
|
-
* @param args
|
|
34
|
-
* @param options
|
|
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
|
-
{"version":3,"file":"PostgrestClient.d.ts","sourceRoot":"","sources":["../../src/PostgrestClient.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,MAAM,yBAAyB,CAAA;AAC3D,OAAO,sBAAsB,MAAM,0BAA0B,CAAA;AAG7D,OAAO,EAAE,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAE9C,MAAM,CAAC,OAAO,OAAO,eAAe,CAClC,QAAQ,GAAG,GAAG,EACd,UAAU,SAAS,MAAM,GAAG,MAAM,QAAQ,GAAG,QAAQ,SAAS,MAAM,QAAQ,GACxE,QAAQ,GACR,MAAM,GAAG,MAAM,QAAQ,EA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|
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
|
|
15
|
-
* @param
|
|
16
|
-
* @param
|
|
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
|
|
36
|
-
* @param args
|
|
37
|
-
* @param options
|
|
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
|
|
1
|
+
{"version":3,"file":"PostgrestClient.js","sourceRoot":"","sources":["../../src/PostgrestClient.ts"],"names":[],"mappings":";;;;;AAAA,oFAA2D;AAC3D,sFAA6D;AAE7D,2CAA6C;AAG7C;;;;;;;;;GASG;AACH,MAAqB,eAAe;IAclC,mEAAmE;IACnE;;;;;;;;OAQG;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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' | '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
|
-
*
|
|
5
|
+
* Match only rows where `column` is equal to `value`.
|
|
9
6
|
*
|
|
10
|
-
*
|
|
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
|
|
30
|
-
* @param value
|
|
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
|
-
*
|
|
36
|
-
* specified `value`.
|
|
15
|
+
* Match only rows where `column` is not equal to `value`.
|
|
37
16
|
*
|
|
38
|
-
* @param column
|
|
39
|
-
* @param value
|
|
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
|
-
*
|
|
45
|
-
* specified `value`.
|
|
23
|
+
* Match only rows where `column` is greater than `value`.
|
|
46
24
|
*
|
|
47
|
-
* @param column
|
|
48
|
-
* @param value
|
|
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
|
-
*
|
|
54
|
-
* equal to the specified `value`.
|
|
31
|
+
* Match only rows where `column` is greater than or equal to `value`.
|
|
55
32
|
*
|
|
56
|
-
* @param column
|
|
57
|
-
* @param value
|
|
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
|
-
*
|
|
63
|
-
* specified `value`.
|
|
39
|
+
* Match only rows where `column` is less than `value`.
|
|
64
40
|
*
|
|
65
|
-
* @param column
|
|
66
|
-
* @param value
|
|
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
|
-
*
|
|
72
|
-
* to the specified `value`.
|
|
47
|
+
* Match only rows where `column` is less than or equal to `value`.
|
|
73
48
|
*
|
|
74
|
-
* @param column
|
|
75
|
-
* @param value
|
|
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
|
-
*
|
|
81
|
-
* `pattern` (case sensitive).
|
|
55
|
+
* Match only rows where `column` matches `pattern` case-sensitively.
|
|
82
56
|
*
|
|
83
|
-
* @param column
|
|
84
|
-
* @param pattern
|
|
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
|
-
*
|
|
90
|
-
* `pattern` (case insensitive).
|
|
63
|
+
* Match only rows where `column` matches `pattern` case-insensitively.
|
|
91
64
|
*
|
|
92
|
-
* @param column
|
|
93
|
-
* @param pattern
|
|
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
|
-
*
|
|
99
|
-
*
|
|
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
|
|
102
|
-
* @param value
|
|
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
|
-
*
|
|
108
|
-
* specified `values`.
|
|
85
|
+
* Match only rows where `column` is included in the `values` array.
|
|
109
86
|
*
|
|
110
|
-
* @param column
|
|
111
|
-
* @param values
|
|
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
|
-
*
|
|
117
|
-
* contains
|
|
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
|
|
120
|
-
* @param value
|
|
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
|
-
*
|
|
126
|
-
*
|
|
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
|
|
129
|
-
* @param value
|
|
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
|
-
*
|
|
135
|
-
*
|
|
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
|
|
138
|
-
* @param range
|
|
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
|
-
*
|
|
153
|
-
*
|
|
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
|
|
156
|
-
* @param range
|
|
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
|
-
*
|
|
162
|
-
*
|
|
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
|
|
165
|
-
* @param range
|
|
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
|
-
*
|
|
171
|
-
*
|
|
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
|
|
174
|
-
* @param range
|
|
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
|
-
*
|
|
180
|
-
*
|
|
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
|
|
183
|
-
* @param value
|
|
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
|
-
*
|
|
189
|
-
* the
|
|
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
|
|
192
|
-
* @param query
|
|
193
|
-
* @param
|
|
194
|
-
* @param
|
|
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
|
-
*
|
|
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
|
|
208
|
-
*
|
|
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
|
-
|
|
212
|
-
|
|
192
|
+
match<ColumnName extends string & keyof Row>(query: Record<ColumnName, Row[ColumnName]>): this;
|
|
193
|
+
match(query: Record<string, unknown>): this;
|
|
213
194
|
/**
|
|
214
|
-
*
|
|
195
|
+
* Match only rows which doesn't satisfy the filter.
|
|
215
196
|
*
|
|
216
|
-
*
|
|
217
|
-
*
|
|
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
|
-
|
|
220
|
-
|
|
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
|