Skip to content

Commit d0f3915

Browse files
authored
docs(js): deprioritize & clarify .filter() syntax (supabase#3566)
1 parent 95c8f7e commit d0f3915

File tree

2 files changed

+101
-97
lines changed

2 files changed

+101
-97
lines changed

web/spec/dart.yml

Lines changed: 53 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ info:
7070
- name: 'Filters'
7171
items:
7272
- Using Filters
73-
- .filter()
7473
- .or()
7574
- .not()
7675
- .match()
@@ -93,6 +92,7 @@ info:
9392
- .rangeAdjacent()
9493
- .overlaps()
9594
- .textSearch()
95+
- .filter()
9696
pages:
9797
Installing:
9898
description: |
@@ -1197,56 +1197,6 @@ pages:
11971197
.execute();
11981198
```
11991199
1200-
.filter():
1201-
description: |
1202-
Finds all rows whose `column` satisfies the filter.
1203-
examples:
1204-
- name: With `select()`
1205-
isSpotlight: true
1206-
dart: |
1207-
```dart
1208-
final res = await supabase
1209-
.from('cities')
1210-
.select('name, country_id')
1211-
.filter('name', 'eq', 'Paris')
1212-
.execute();
1213-
```
1214-
- name: With `update()`
1215-
dart: |
1216-
```dart
1217-
final res = await supabase
1218-
.from('cities')
1219-
.update({ 'name': 'Mordor' })
1220-
.filter('name', 'eq', 'Paris')
1221-
.execute();
1222-
```
1223-
- name: With `delete()`
1224-
dart: |
1225-
```dart
1226-
final res = await supabase
1227-
.from('cities')
1228-
.delete()
1229-
.filter('name', 'eq', 'Paris')
1230-
.execute();
1231-
```
1232-
- name: With `rpc()`
1233-
dart: |
1234-
```dart
1235-
// Only valid if the Stored Procedure returns a table type.
1236-
final res = await supabase
1237-
.rpc('echo_all_cities')
1238-
.filter('name', 'eq', 'Paris')
1239-
```
1240-
- name: Filter embedded resources
1241-
dart: |
1242-
```dart
1243-
final res = await supabase
1244-
.from('cities')
1245-
.select('name, countries ( name )')
1246-
.filter('countries.name', 'eq', 'France')
1247-
.execute();
1248-
```
1249-
12501200
.or():
12511201
description: |
12521202
Finds all rows satisfying at least one of the filters.
@@ -2176,3 +2126,55 @@ pages:
21762126
)
21772127
.execute();
21782128
```
2129+
2130+
.filter():
2131+
description: |
2132+
Finds all rows whose `column` satisfies the filter.
2133+
notes: |
2134+
- `.filter()` expects you to use the raw [PostgREST syntax](https://postgrest.org/en/stable/api.html#horizontal-filtering-rows) for the filter values, so it should only be used as an escape hatch in case other filters don't work.
2135+
examples:
2136+
- name: With `select()`
2137+
isSpotlight: true
2138+
dart: |
2139+
```dart
2140+
final res = await supabase
2141+
.from('cities')
2142+
.select('name, country_id')
2143+
.filter('name', 'in', '("Paris","Tokyo")')
2144+
.execute();
2145+
```
2146+
- name: With `update()`
2147+
dart: |
2148+
```dart
2149+
final res = await supabase
2150+
.from('cities')
2151+
.update({ 'name': 'Mordor' })
2152+
.filter('name', 'in', '("Paris","Tokyo")')
2153+
.execute();
2154+
```
2155+
- name: With `delete()`
2156+
dart: |
2157+
```dart
2158+
final res = await supabase
2159+
.from('cities')
2160+
.delete()
2161+
.filter('name', 'in', '("Paris","Tokyo")')
2162+
.execute();
2163+
```
2164+
- name: With `rpc()`
2165+
dart: |
2166+
```dart
2167+
// Only valid if the Stored Procedure returns a table type.
2168+
final res = await supabase
2169+
.rpc('echo_all_cities')
2170+
.filter('name', 'in', '("Paris","Tokyo")')
2171+
```
2172+
- name: Filter embedded resources
2173+
dart: |
2174+
```dart
2175+
final res = await supabase
2176+
.from('cities')
2177+
.select('name, countries ( name )')
2178+
.filter('countries.name', 'in', '("France","Japan")')
2179+
.execute();
2180+
```

web/spec/supabase.yml

Lines changed: 48 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@ info:
7979
- name: 'Filters'
8080
items:
8181
- Using Filters
82-
- .filter()
8382
- .or()
8483
- .not()
8584
- .match()
@@ -102,6 +101,7 @@ info:
102101
- .rangeAdjacent()
103102
- .overlaps()
104103
- .textSearch()
104+
- .filter()
105105

106106
pages:
107107
Installing:
@@ -1335,51 +1335,6 @@ pages:
13351335
.lt('population', 10000)
13361336
```
13371337
1338-
.filter():
1339-
$ref: '@supabase/postgrest-js."lib/PostgrestFilterBuilder".PostgrestFilterBuilder.filter'
1340-
examples:
1341-
- name: With `select()`
1342-
isSpotlight: true
1343-
js: |
1344-
```js
1345-
const { data, error } = await supabase
1346-
.from('cities')
1347-
.select('name, country_id')
1348-
.filter('name', 'eq', 'Paris')
1349-
```
1350-
- name: With `update()`
1351-
js: |
1352-
```js
1353-
const { data, error } = await supabase
1354-
.from('cities')
1355-
.update({ name: 'Mordor' })
1356-
.filter('name', 'eq', 'Paris')
1357-
```
1358-
- name: With `delete()`
1359-
js: |
1360-
```js
1361-
const { data, error } = await supabase
1362-
.from('cities')
1363-
.delete()
1364-
.filter('name', 'eq', 'Paris')
1365-
```
1366-
- name: With `rpc()`
1367-
js: |
1368-
```js
1369-
// Only valid if the Postgres function returns a table type.
1370-
const { data, error } = await supabase
1371-
.rpc('echo_all_cities')
1372-
.filter('name', 'eq', 'Paris')
1373-
```
1374-
- name: Filter embedded resources
1375-
js: |
1376-
```js
1377-
const { data, error } = await supabase
1378-
.from('cities')
1379-
.select('name, countries ( name )')
1380-
.filter('countries.name', 'eq', 'France')
1381-
```
1382-
13831338
.or():
13841339
$ref: '@supabase/postgrest-js."lib/PostgrestFilterBuilder".PostgrestFilterBuilder.or'
13851340
examples:
@@ -2209,3 +2164,50 @@ pages:
22092164
config: 'english'
22102165
})
22112166
```
2167+
2168+
.filter():
2169+
$ref: '@supabase/postgrest-js."lib/PostgrestFilterBuilder".PostgrestFilterBuilder.filter'
2170+
notes: |
2171+
- `.filter()` expects you to use the raw [PostgREST syntax](https://postgrest.org/en/stable/api.html#horizontal-filtering-rows) for the filter values, so it should only be used as an escape hatch in case other filters don't work.
2172+
examples:
2173+
- name: With `select()`
2174+
isSpotlight: true
2175+
js: |
2176+
```js
2177+
const { data, error } = await supabase
2178+
.from('cities')
2179+
.select('name, country_id')
2180+
.filter('name', 'in', '("Paris","Tokyo")')
2181+
```
2182+
- name: With `update()`
2183+
js: |
2184+
```js
2185+
const { data, error } = await supabase
2186+
.from('cities')
2187+
.update({ name: 'Mordor' })
2188+
.filter('name', 'in', '("Paris","Tokyo")')
2189+
```
2190+
- name: With `delete()`
2191+
js: |
2192+
```js
2193+
const { data, error } = await supabase
2194+
.from('cities')
2195+
.delete()
2196+
.filter('name', 'in', '("Paris","Tokyo")')
2197+
```
2198+
- name: With `rpc()`
2199+
js: |
2200+
```js
2201+
// Only valid if the Postgres function returns a table type.
2202+
const { data, error } = await supabase
2203+
.rpc('echo_all_cities')
2204+
.filter('name', 'in', '("Paris","Tokyo")')
2205+
```
2206+
- name: Filter embedded resources
2207+
js: |
2208+
```js
2209+
const { data, error } = await supabase
2210+
.from('cities')
2211+
.select('name, countries ( name )')
2212+
.filter('countries.name', 'in', '("France","Japan")')
2213+
```

0 commit comments

Comments
 (0)