You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Oct 9, 2025. It is now read-only.
let client =newPostgrestClient('https://your-postgrest.com')
33
-
```
34
-
35
-
#### PostgrestClient(postgrestURL, OPTIONS)
36
-
`postgrestURL: string`
37
-
38
-
The URL from where your postgREST queries.
39
-
40
-
`OPTIONS: object?`
41
-
```js
42
-
/**
43
-
* @param{object?}headers
44
-
* List of headers as keys and their corresponding values
45
-
*
46
-
* @param{object?}query_params
47
-
* List of query parameters as keys and their corresponding values
48
-
*
49
-
* @param{string}schema
50
-
* If you are using postgREST version v7.0.0 and above,
51
-
* you can use this to indicate your selected schema.
52
-
* This is provided that your schema is included in db-schema
53
-
*/
54
-
```
55
-
To know more about multi schema and swithching between schema, more information can be found [here](http://postgrest.org/en/v7.0.0/configuration.html#db-schema).
56
-
57
-
### GET
58
-
These filters also support our `PATCH` and `DELETE` actions as well. More information on our filters can be found [here](https://supabase.io/docs/library/get#filter_).
59
-
60
-
```js
61
-
62
-
// Basic
63
-
let { body: countries } =await client
64
-
.from('countries')
65
-
.select('*')
66
-
67
-
// Getting specific columns
68
-
let { body: countries } =await client
69
-
.from('countries')
70
-
.select('name')
71
-
72
-
// Query foreign tables
73
-
let { body: countries } =await client
74
-
.from('countries')
75
-
.select(`
76
-
name,
77
-
cities (
78
-
name
79
-
)
80
-
`)
81
-
82
-
// Filter foreign tables
83
-
let { body: countries } =await client
84
-
.from('countries')
85
-
.select(`
86
-
name,
87
-
cities (
88
-
name
89
-
)
90
-
`)
91
-
.filter('name', 'eq', 'New Zealand')
92
-
.filter('cities.name', 'eq', 'Auckland')
93
-
94
-
// Not (the reverse of .filter())
95
-
let { body: countries } =await client
96
-
.from('countries')
97
-
.select(`
98
-
name,
99
-
cities (
100
-
name
101
-
)
102
-
`)
103
-
.not('name', 'eq', 'New Zealand')
104
-
.not('cities.name', 'eq', 'Auckland')
105
-
106
-
// Ordering
107
-
let { body: countries } =await client
108
-
.from('countries')
109
-
.select('name')
110
-
.order('name')
111
-
112
-
// Ordering for foreign tables
113
-
let { body: countries } =await client
114
-
.from('countries')
115
-
.select(`
116
-
name,
117
-
cities (
118
-
name
119
-
)
120
-
`)
121
-
.order('cities.name')
122
-
123
-
// Limiting
124
-
let { body: countries } =await client
125
-
.from('countries')
126
-
.select('*')
127
-
.limit(1)
128
-
129
-
// Limiting for foreign tables
130
-
let { body: countries } =await client
131
-
.from('countries')
132
-
.select(`
133
-
name,
134
-
cities (
135
-
name
136
-
)
137
-
`)
138
-
.limit(1, 'cities')
139
-
140
-
// Setting offsets
141
-
let { body: countries } =await client
142
-
.from('countries')
143
-
.select('*')
144
-
.offset(1)
145
-
146
-
// Setting offsets for foreign tables
147
-
let { body: countries } =await client
148
-
.from('countries')
149
-
.select(`
150
-
name,
151
-
cities (
152
-
name
153
-
)
154
-
`)
155
-
.offset(1, 'cities')
156
-
157
-
// Pagination
158
-
let { body: countries } =await client
159
-
.from('countries')
160
-
.select('name')
161
-
.range(0, 10)
162
-
163
-
// Match
164
-
let { body: countries } =await client
165
-
.from('countries')
166
-
.match({ 'continent':'Asia' })
167
-
.select('*')
168
-
169
-
// Equal
170
-
let { body: countries } =await client
171
-
.from('countries')
172
-
.eq('name', 'New Zealand')
173
-
.select('*')
174
-
175
-
// Greater than
176
-
let { body: countries } =await client
177
-
.from('countries')
178
-
.gt('id', 20)
179
-
.select('*')
180
-
181
-
// Less than
182
-
let { body: countries } =await client
183
-
.from('countries')
184
-
.lt('id', 20)
185
-
.select('*')
186
-
187
-
// Greater than or equal
188
-
let { body: countries } =await client
189
-
.from('countries')
190
-
.gte('id', 20)
191
-
.select('*')
192
-
193
-
// Less than or equal
194
-
let { body: countries } =await client
195
-
.from('countries')
196
-
.lte('id', 20)
197
-
.select('*')
198
-
199
-
// String search - case sensitive
200
-
let { body: countries } =await client
201
-
.from('countries')
202
-
.like('name', '%Zeal%')
203
-
.select('*')
204
-
205
-
// String search - case insensitive
206
-
let { body: countries } =await client
207
-
.from('countries')
208
-
.ilike('name', '%Zeal%')
209
-
.select('*')
210
-
211
-
// Exact equality (null, true, false)
212
-
let { body: countries } =await client
213
-
.from('countries')
214
-
.is('name', null)
215
-
.select('*')
216
-
217
-
// In list
218
-
let { body: countries } =await client
219
-
.from('countries')
220
-
.in('name', ['China', 'France'])
221
-
.select('*')
222
-
223
-
// Not equal
224
-
let { body: countries } =await client
225
-
.from('countries')
226
-
.neq('name', 'China')
227
-
.select('*')
228
-
229
-
// Contains
230
-
let { body: countries } =await client
231
-
.from('countries')
232
-
.cs('main_exports', ['oil'])
233
-
.select('*')
234
-
235
-
// Contained in
236
-
let { body: countries } =await client
237
-
.from('countries')
238
-
.cd('main_exports', ['cars', 'food', 'machine'])
239
-
.select('*')
240
-
241
-
// Overlaps (for arrays)
242
-
let { body: countries } =await client
243
-
.from('countries')
244
-
.ova('main_exports', ['computers', 'minerals'])
245
-
.select('*')
246
-
247
-
// Overlaps (for ranges)
248
-
let { body: countries } =await client
249
-
.from('countries')
250
-
.ovr('population_range_millions', [150, 250])
251
-
.select('*')
252
-
253
-
// Strictly left
254
-
let { body: countries } =await client
255
-
.from('countries')
256
-
.sl('population_range_millions', [150, 250])
257
-
.select('*')
258
-
259
-
// Strictly right
260
-
let { body: countries } =await client
261
-
.from('countries')
262
-
.sr('population_range_millions', [150, 250])
263
-
.select('*')
264
-
265
-
// Does not extend to the left
266
-
let { body: countries } =await client
267
-
.from('countries')
268
-
.nxl('population_range_millions', [150, 250])
269
-
.select('*')
270
-
271
-
// Does not extend to the right
272
-
let { body: countries } =await client
273
-
.from('countries')
274
-
.nxr('population_range_millions', [150, 250])
275
-
.select('*')
276
-
277
-
// Adjacent
278
-
let { body: countries } =await client
279
-
.from('countries')
280
-
.adj('population_range_millions', [70, 185])
281
-
.select('*')
282
-
283
-
```
284
-
285
-
286
-
### POST
287
-
288
-
You can insert records using `insert()`. Insert accepts an array of objects so that you can batch insert.
0 commit comments