Skip to content

Commit 1c32d55

Browse files
docs: add more filtering examples to the API docs (supabase#33899)
- Add logical operators "not" and "or" - All Javascript examples are now present for Bash Co-authored-by: Terry Sutton <saltcod@gmail.com>
1 parent 66d1f40 commit 1c32d55

File tree

2 files changed

+56
-4
lines changed

2 files changed

+56
-4
lines changed

apps/studio/components/interfaces/Docs/Snippets.ts

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -342,10 +342,31 @@ let { data: ${resourceId}, error } = await supabase
342342
bash: {
343343
language: 'bash',
344344
code: `
345-
curl '${endpoint}/rest/v1/${resourceId}?id=eq.1&select=*' \\
345+
curl --get '${endpoint}/rest/v1/${resourceId}' \\
346346
-H "apikey: ${apiKey}" \\
347347
-H "Authorization: Bearer ${apiKey}" \\
348-
-H "Range: 0-9"
348+
-H "Range: 0-9" \\
349+
-d "select=*" \\
350+
\\
351+
\`# Filters\` \\
352+
-d "column=eq.Equal+to" \\
353+
-d "column=gt.Greater+than" \\
354+
-d "column=lt.Less+than" \\
355+
-d "column=gte.Greater+than+or+equal+to" \\
356+
-d "column=lte.Less+than+or+equal+to" \\
357+
-d "column=like.*CaseSensitive*" \\
358+
-d "column=ilike.*CaseInsensitive*" \\
359+
-d "column=is.null" \\
360+
-d "column=in.(Array,Values)" \\
361+
-d "column=neq.Not+equal+to" \\
362+
\\
363+
\`# Arrays\` \\
364+
-d "array_column=cs.{array,contains}" \\
365+
-d "array_column=cd.{contained,by}" \\
366+
\\
367+
\`# Logical operators\` \\
368+
-d "column=not.like.Negate+filter" \\
369+
-d "or=(some_column.eq.Some+value,other_column.eq.Other+value)"
349370
`,
350371
},
351372
js: {
@@ -354,6 +375,7 @@ curl '${endpoint}/rest/v1/${resourceId}?id=eq.1&select=*' \\
354375
let { data: ${resourceId}, error } = await supabase
355376
.from('${resourceId}')
356377
.select("*")
378+
357379
// Filters
358380
.eq('column', 'Equal to')
359381
.gt('column', 'Greater than')
@@ -365,9 +387,14 @@ let { data: ${resourceId}, error } = await supabase
365387
.is('column', null)
366388
.in('column', ['Array', 'Values'])
367389
.neq('column', 'Not equal to')
390+
368391
// Arrays
369392
.contains('array_column', ['array', 'contains'])
370393
.containedBy('array_column', ['contained', 'by'])
394+
395+
// Logical operators
396+
.not('column', 'like', 'Negate filter')
397+
.or('some_column.eq.Some value, other_column.eq.Other value')
371398
`,
372399
},
373400
}),

apps/studio/components/interfaces/ProjectAPIDocs/ProjectAPIDocs.constants.ts

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -722,10 +722,31 @@ let { data: ${resourceId}, error } = await supabase
722722
key: 'with-filtering',
723723
title: 'With filtering',
724724
bash: `
725-
curl '${endpoint}/rest/v1/${resourceId}?id=eq.1&select=*' \\
725+
curl --get '${endpoint}/rest/v1/${resourceId}' \\
726726
-H "apikey: ${apikey}" \\
727727
-H "Authorization: Bearer ${apikey}" \\
728-
-H "Range: 0-9"
728+
-H "Range: 0-9" \\
729+
-d "select=*" \\
730+
\\
731+
\`# Filters\` \\
732+
-d "column=eq.Equal+to" \\
733+
-d "column=gt.Greater+than" \\
734+
-d "column=lt.Less+than" \\
735+
-d "column=gte.Greater+than+or+equal+to" \\
736+
-d "column=lte.Less+than+or+equal+to" \\
737+
-d "column=like.*CaseSensitive*" \\
738+
-d "column=ilike.*CaseInsensitive*" \\
739+
-d "column=is.null" \\
740+
-d "column=in.(Array,Values)" \\
741+
-d "column=neq.Not+equal+to" \\
742+
\\
743+
\`# Arrays\` \\
744+
-d "array_column=cs.{array,contains}" \\
745+
-d "array_column=cd.{contained,by}" \\
746+
\\
747+
\`# Logical operators\` \\
748+
-d "column=not.like.Negate+filter" \\
749+
-d "or=(some_column.eq.Some+value,other_column.eq.Other+value)"
729750
`,
730751
js: `
731752
let { data: ${resourceId}, error } = await supabase
@@ -747,6 +768,10 @@ let { data: ${resourceId}, error } = await supabase
747768
// Arrays
748769
.contains('array_column', ['array', 'contains'])
749770
.containedBy('array_column', ['contained', 'by'])
771+
772+
// Logical operators
773+
.not('column', 'like', 'Negate filter')
774+
.or('some_column.eq.Some value, other_column.eq.Other value')
750775
`,
751776
},
752777
]

0 commit comments

Comments
 (0)