@@ -4,6 +4,16 @@ import PostgrestBuilder from './PostgrestBuilder'
4
4
import { DEFAULT_HEADERS } from './constants'
5
5
import { Fetch , GenericSchema } from './types'
6
6
7
+ /**
8
+ * PostgREST client.
9
+ *
10
+ * @typeParam Database - Types for the schema from the [type
11
+ * generator](https://supabase.com/docs/reference/javascript/next/typescript-support)
12
+ *
13
+ * @typeParam SchemaName - Postgres schema to switch to. Must be a string
14
+ * literal, the same one passed to the constructor. If the schema is not
15
+ * `"public"`, this must be supplied manually.
16
+ */
7
17
export default class PostgrestClient <
8
18
Database = any ,
9
19
SchemaName extends string & keyof Database = 'public' extends keyof Database
@@ -22,9 +32,11 @@ export default class PostgrestClient<
22
32
/**
23
33
* Creates a PostgREST client.
24
34
*
25
- * @param url URL of the PostgREST endpoint.
26
- * @param headers Custom headers.
27
- * @param schema Postgres schema to switch to.
35
+ * @param url - URL of the PostgREST endpoint
36
+ * @param options - Named parameters
37
+ * @param options.headers - Custom headers
38
+ * @param options.schema - Postgres schema to switch to
39
+ * @param options.fetch - Custom fetch
28
40
*/
29
41
constructor (
30
42
url : string ,
@@ -47,7 +59,7 @@ export default class PostgrestClient<
47
59
/**
48
60
* Perform a query on a table or a view.
49
61
*
50
- * @param relation The table or view name to query.
62
+ * @param relation - The table or view name to query
51
63
*/
52
64
from <
53
65
TableName extends string & keyof Schema [ 'Tables' ] ,
@@ -69,9 +81,23 @@ export default class PostgrestClient<
69
81
/**
70
82
* Perform a function call.
71
83
*
72
- * @param fn The function name to call.
73
- * @param args The parameters to pass to the function call.
74
- * @param options Named parameters.
84
+ * @param fn - The function name to call
85
+ * @param args - The arguments to pass to the function call
86
+ * @param options - Named parameters
87
+ * @param options.head - When set to `true`, `data` will not be returned.
88
+ * Useful if you only need the count.
89
+ * @param options.count - Count algorithm to use to count rows returned by the
90
+ * function. Only applicable for [set-returning
91
+ * functions](https://www.postgresql.org/docs/current/functions-srf.html).
92
+ *
93
+ * `"exact"`: Exact but slow count algorithm. Performs a `COUNT(*)` under the
94
+ * hood.
95
+ *
96
+ * `"planned"`: Approximated but fast count algorithm. Uses the Postgres
97
+ * statistics under the hood.
98
+ *
99
+ * `"estimated"`: Uses exact count for low numbers and planned count for high
100
+ * numbers.
75
101
*/
76
102
rpc <
77
103
FunctionName extends string & keyof Schema [ 'Functions' ] ,
@@ -83,9 +109,7 @@ export default class PostgrestClient<
83
109
head = false ,
84
110
count,
85
111
} : {
86
- /** When set to true, no data will be returned. */
87
112
head ?: boolean
88
- /** Count algorithm to use to count rows in a table. */
89
113
count ?: 'exact' | 'planned' | 'estimated'
90
114
} = { }
91
115
) : PostgrestFilterBuilder <
0 commit comments