mirror of
https://github.com/supabase/supabase.git
synced 2026-10-17 23:29:08 +03:00
commit863b287eefAuthor: Aleksi Immonen <aleksi@supabase.io> Date: Tue Jan 28 14:48:46 2025 +0200 Fix www and studio events description grammar/style (#33146) * Update telemetry-constants.ts Fix: www and studio events description grammar and style * Update telemetry-constants.ts commite770d1322fAuthor: Joshen Lim <joshenlimek@gmail.com> Date: Tue Jan 28 17:23:17 2025 +0800 Support dupe query (#33113) * Support dupe query * Update * Small refactor commit36637a8c94Author: Joshen Lim <joshenlimek@gmail.com> Date: Tue Jan 28 17:09:17 2025 +0800 SQL editor persist open close state of each section (#33112) * SQL editor persist open close state of each section * Address feedback commit84ff943f8fAuthor: Copple <10214025+kiwicopple@users.noreply.github.com> Date: Tue Jan 28 15:42:40 2025 +1300 chore: update self-hosted image versions (#33136) chore: update image versions for docker/docker-compose.yml commit3f9e93d659Author: Kang Ming <kang.ming1996@gmail.com> Date: Mon Jan 27 17:22:46 2025 -0800 docs: update phone auth docs (#33135) * docs: state that whatsapp is only supported for Twilio * docs: update format in callout * docs: include twilio verify * fixing capitalization --------- Co-authored-by: Brian B (theOtherBrian1) <brian@supabase.io> commita5b51862b9Author: Charis <26616127+charislam@users.noreply.github.com> Date: Mon Jan 27 19:26:37 2025 -0500 fix:error filter for troubleshooting (#33010) Fix error codes not showing up or not filtering properly in troubleshooting filter. Also fix local dev when local infra is not available. commita255acb5eaAuthor: Charis <26616127+charislam@users.noreply.github.com> Date: Mon Jan 27 16:29:29 2025 -0500 chore: add auto-troubleshooting-template to local dev (#33128) Small DX improvement for writing troubleshooting guides. When a new troubleshooting guide is created, it is auto-populated with the tempalte (as long as docs dev is running). commitf3df883c06Author: Greg Richardson <greg.nmr@gmail.com> Date: Mon Jan 27 12:03:46 2025 -0700 fix: adds fallback when wasm is not supported (#33126) commitd35855cb58Author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon Jan 27 18:09:58 2025 +0000 feat: update mgmt api docs (#33104) Co-authored-by: phamhieu <689843+phamhieu@users.noreply.github.com> commitaca05551d1Author: Joshen Lim <joshenlimek@gmail.com> Date: Tue Jan 28 00:24:46 2025 +0800 Update GetStartedHero (#33123) commit8b9d5736e4Author: Ivan Vasilov <vasilov.ivan@gmail.com> Date: Mon Jan 27 14:42:27 2025 +0100 chore: Fix Monaco editor in strict mode (#33075) * Move the code for adding code completion definitions to Monaco instance from the sql editor page to a hook. * Use the hook the in the SQL Editor. commit8f90c86050Author: Ivan Vasilov <vasilov.ivan@gmail.com> Date: Mon Jan 27 14:32:03 2025 +0100 chore: Use `react-query` cache for file previews (#23398) * Empty spaces. * Remove prop drilling for selectedFilePreview and just use it from the store. * Add a hook for getting a fetch url. Use it in all places where it's needed. Remove the file cache from the store. * Simplify the onCopyUrl hook further. * Fix some bugs in the preview pane. commit98ca85156aAuthor: Ivan Vasilov <vasilov.ivan@gmail.com> Date: Mon Jan 27 13:04:31 2025 +0100 chore: Use `sql-formatter` for formatting all SQL in the `studio` (#33071) * Bump the sql-formatter dependency. * Add a function formatQuery which is a wrapper around sql-formatter. * Replace all formatSQL features to use the new function formatSql. * Remove unneeded RQ for formatting. * Small fix. commitdbd6c3866dAuthor: Ivan Vasilov <vasilov.ivan@gmail.com> Date: Mon Jan 27 13:03:44 2025 +0100 chore: Bump all versions of `vitest` to the v3+. Fix a vuln in `vite` (#33041) * Bump all versions of vitest to the v3+. * Bump vite to a non-vulnerable version (5.4.12). commitcf75f7a33eAuthor: Jordi Enric <37541088+jordienr@users.noreply.github.com> Date: Mon Jan 27 12:02:50 2025 +0100 Notification filters: fix icon size (#33117) * fix icon size * undo notifpopover * undo notifpopover commitc96bd5c107Author: Kevin Grüneberg <k.grueneberg1994@gmail.com> Date: Mon Jan 27 18:34:07 2025 +0800 refactor: database size metric for Free Plan (#33039) Instead of basing the database size metric for the Free Plan on summing up the average database size per project in the organization, we are going to simply enforce a database size limit of 0.5 GB per active project. Deleted projects are irrelevant and it should be much easier for customers to understand. We are querying the database size directly via the project to avoid delays. commit4425e05f04Author: Joshen Lim <joshenlimek@gmail.com> Date: Mon Jan 27 15:40:51 2025 +0800 Update SQL editor search to return a flat list (#33064) * Update SQL editor search to return a flat list * Open folder when clicking on a snippet from searching and snippet belongs to a folder * Update snipet page limit * Set keep previous data true for count * Add hover card for SQL search list * Fix issues from feedback * Make count loader less jarring commit1a3a8cb353Author: Joshen Lim <joshenlimek@gmail.com> Date: Mon Jan 27 15:17:36 2025 +0800 Add colors quickstart SQL (#33107) * Add colors quickstart SQL * Update enum to be UPPER_CAMEL_CASE commite20c36c505Author: Joshen Lim <joshenlimek@gmail.com> Date: Mon Jan 27 15:08:26 2025 +0800 Smol fix (#33109) commit3b6a4cd0e2Author: Andrew Valleteau <avallete@users.noreply.github.com> Date: Mon Jan 27 14:17:15 2025 +0900 chore(docs): add new postgres-config delete command docs (#32982) * chore(docs): add new postgres-config delete command docs * chore: docs rephrase * chore: rewrite * chore: update common-cli-sections commit7ad4ad6ee5Author: Charis <26616127+charislam@users.noreply.github.com> Date: Fri Jan 24 21:54:37 2025 -0500 fix: multi-select (#32777) Multi-select has an always-on scrollbar gutter, which is a bit strange-looking and not identifiable as a scrollbar gutter when there's nothing to scroll (I thought it was some weird border for a long time...) Removing it makes it look a bit better commitd5853c7ff3Author: hallidayo <22655069+Hallidayo@users.noreply.github.com> Date: Sat Jan 25 02:09:18 2025 +0000 docs: access control operator type (#33056) cast to text commitf9c2397faaAuthor: Charis <26616127+charislam@users.noreply.github.com> Date: Fri Jan 24 20:58:59 2025 -0500 fix: prisma docs (#33017) Replace hardcoded region with placeholder string commita36145494aAuthor: Kamil Ogórek <kamil.ogorek@gmail.com> Date: Fri Jan 24 19:55:50 2025 +0100 docs: Update permissions for Database scope (#33067) commit1c05181eaaAuthor: Greg Richardson <greg.nmr@gmail.com> Date: Fri Jan 24 09:27:23 2025 -0700 blog: change postgres.new links to database.build (#33076) commit219962e0e3Author: Kamil Ogórek <kamil.ogorek@gmail.com> Date: Fri Jan 24 16:07:33 2025 +0100 misc: Disable Sentry Tracing (#33072) commit89c324af84Author: Terry Sutton <saltcod@gmail.com> Date: Fri Jan 24 11:25:41 2025 -0330 fixed: infinite loading in storage explorer rows (#33051) * fixed: infinite loading in storage explorer rows * prettier --------- Co-authored-by: Dhairya Shah <hello@dhairyashah.dev> commit95dccf3cd9Author: Filipe Cabaço <filipe@supabase.io> Date: Fri Jan 24 12:01:49 2025 +0000 realtime: Bump up image (#33066) commitdf6e6c6f8bAuthor: Pamela Chia <pamelachiamayyee@gmail.com> Date: Fri Jan 24 14:49:32 2025 +0800 Feat/add www events (#33031) * feat: add card click events in other pages * feat: add location for hero, nav and banner button clicks * add request demo form event * add newline for long comment/descriptions commit3aec212a60Author: Joshen Lim <joshenlimek@gmail.com> Date: Fri Jan 24 11:08:36 2025 +0800 Hide RLS button for tables in protected schemas (#33038) commit3f6adea49cAuthor: Wen Bo Xie <5532241+w3b6x9@users.noreply.github.com> Date: Thu Jan 23 17:50:10 2025 -0500 fix: change functions dependencies url (#33050) * fix: change functions dependencies url * change file name to dependencies.mdx commitd15ae65316Author: Kevin Rocker <kjrocker@users.noreply.github.com> Date: Thu Jan 23 21:43:32 2025 +0100 docs: add async/await JS example to message broadcasting (#31232) * docs: add async/await JS example to message broadcasting * Update Documentation * Make async example more async * Channel name update * Run formatter --------- Co-authored-by: Charis <26616127+charislam@users.noreply.github.com> commitc4b6becdb9Author: Alaister Young <alaister@users.noreply.github.com> Date: Fri Jan 24 02:04:37 2025 +0800 chore: sentry capture profile creation errors (#33048) commit99a042eccaAuthor: Ivan Vasilov <vasilov.ivan@gmail.com> Date: Thu Jan 23 18:06:36 2025 +0100 chore: Set an override for @supabase/auth-js (#33043) Set an override for @supabase/auth-js. commitd8b034ad69Author: Saxon Fletcher <saxonafletcher@gmail.com> Date: Fri Jan 24 02:39:58 2025 +1000 remove globe dependencies (#33033) * remove globe dependencies * Remove unused imports --------- Co-authored-by: Joshen Lim <joshenlimek@gmail.com> commitf0a24b076fAuthor: Shay Molcho <152275799+shaymolcho@users.noreply.github.com> Date: Thu Jan 23 18:11:51 2025 +0200 Improved punctuation in README (#33040) Enhanced punctuation in the README. These changes enhance the document’s clarity and maintain a uniform structure. commit6477f54610Author: Jordi Enric <37541088+jordienr@users.noreply.github.com> Date: Thu Jan 23 16:12:52 2025 +0100 Add warnings to logs stacked bar chart (#33036) commit64b7775e2eAuthor: Stojan Dimitrovski <sdimitrovski@gmail.com> Date: Thu Jan 23 14:26:05 2025 +0100 feat: bump `auth-js` to RC 2.68.0 (#32999) commit794529eddfAuthor: Joshen Lim <joshenlimek@gmail.com> Date: Thu Jan 23 17:06:28 2025 +0800 Chore/add export functionality to advisors (#33030) * Add export functionality to security and performance advisors * Add download results button to query performance advisor * Add refresh buttons to security and performance advisors * Add LoadingLine to Query performance to make UI consistent with the other advisors * Minor change commit79e656f735Author: Saxon Fletcher <saxonafletcher@gmail.com> Date: Thu Jan 23 17:16:58 2025 +1000 remove globe in onboarding (#33021) commit154dd0d010Author: Joshen Lim <joshenlimek@gmail.com> Date: Thu Jan 23 14:54:28 2025 +0800 Fix SQL block not rendering if its the only block in the report (#33026) * Fix SQL block not rendering if its the only block in the report * Update commit90a939506cAuthor: Joshen Lim <joshenlimek@gmail.com> Date: Thu Jan 23 13:25:31 2025 +0800 Feat/reports v2/misc wrap up (#32989) * Add telemetry for add SQL block and dragging SQL block from assistant * Add UI indication for drag support block in Assistant * Add UI indication for SQL block support in SQL editor Chart options * Feat/reports v2/create report (#33022) * re-add chart label * fix undefined value * remove mouse over on chart --------- Co-authored-by: Saxon Fletcher <saxonafletcher@gmail.com> commitd50fa11757Author: Pamela Chia <pamelachiamayyee@gmail.com> Date: Thu Jan 23 09:20:47 2025 +0800 feat: add homepage click events (#33005) * feat: add homepage click events * fix codeowners telemetry filepath commit439f0391c3Author: Abbas Mkhzomi <amkhzomi@gmail.com> Date: Thu Jan 23 03:00:44 2025 +0330 Update laravel.mdx (#32716) commit7463454424Author: Sandeep Salwan <salwansandeep5@gmail.com> Date: Wed Jan 22 16:48:33 2025 -0500 docs: update auth-azure.mdx (#32730) commit4b87612507Author: GauntletRunner2025 <193957098+GauntletRunner2025@users.noreply.github.com> Date: Wed Jan 22 13:29:30 2025 -0600 Update branching.mdx (#32949) commit30c390c19cAuthor: Alaister Young <alaister@users.noreply.github.com> Date: Wed Jan 22 23:52:32 2025 +0800 chore: unify telemetry event sending (#32861) * chore: unify telemetry event sending * organize some imports * remove final useTelemetryProps * add www telemetry actions typing and docs * remove gaevents * fix build * move telemetry identify into PageTelemetry * fix telemetry constants import --------- Co-authored-by: Pamela Chia <pamelachiamayyee@gmail.com> Co-authored-by: Joshen Lim <joshenlimek@gmail.com> commit1dc92a529dAuthor: Han Qiao <sweatybridge@gmail.com> Date: Wed Jan 22 22:56:40 2025 +0800 docs: update project restore docs for past 90 days backup (#32990) * docs: update project restore docs for past 90 days backup * chore: rephrase a few lines commitfeaf64e55dAuthor: Long Hoang <1732217+loong@users.noreply.github.com> Date: Wed Jan 22 22:41:41 2025 +0800 Fix event grouping (#32928) * fix: pass ref and slug for event grouping * fix: add missing imports * fix: correct types * remove duplicate import * fix: duplicates and extra events from merge --------- Co-authored-by: Pamela Chia <pamelachiamayyee@gmail.com> commitecd7b5f4ddAuthor: Sanden Gocka <sandguitar@gmail.com> Date: Wed Jan 22 02:00:58 2025 -0800 Prototype: Enhance Supabase Studio User Impersonation with External Auth Support (#32786) * feat: add support for impersonation with external auth * update typescript type --------- Co-authored-by: Alaister Young <a@alaisteryoung.com> commit60763ab1e7Author: Joshen Lim <joshenlimek@gmail.com> Date: Wed Jan 22 16:35:52 2025 +0800 Reports V2: support dragging blocks from assistant to custom report (#32964) * Support dragging blocks from assistant to custom report * Show toast when new snippet is created from dragging block into custom report * Only show drag handle for block in assistant panel if in custom reports * Feature flag dragging Assistant query block to custom report * Optimize DX for dragging block into report from assistant * Update import * Remove max width * Fix dragging non sql block causing client crash * Fix chart suffix * Fix tooltip value for non % values * Misc fixes * Support persisting non sql block line or bar view, and fix cancelling not resetting the block state * Update * Preserve chart config when dragging block from assistant to report * Fix commitc635d46b53Author: Joshen Lim <joshenlimek@gmail.com> Date: Wed Jan 22 16:22:45 2025 +0800 Add missing users delete endpoint for local/self-host (#32945) * Add missing users delete endpoint for local/self-host * Update commit45f7561d30Author: Ziinc <Ziinc@users.noreply.github.com> Date: Wed Jan 22 14:26:29 2025 +0800 fix: show database charts at 1h resolution (#32962) * fix: drop default interval * fix: add datepicker override * chore: remove comments commit12645ec023Author: Joshen Lim <joshenlimek@gmail.com> Date: Wed Jan 22 14:26:20 2025 +0800 Fix SQL editor menu wrongly hiding results (#32960) commitcedcc5315fAuthor: Joshen Lim <joshenlimek@gmail.com> Date: Wed Jan 22 14:14:34 2025 +0800 Swap PATCH content to PUT (#32950) * Swap PATCH content to PUT * Fix tests * Swap create Logs Explorer query to use upsert content commit6b4fd6c088Author: Joshen Lim <joshenlimek@gmail.com> Date: Wed Jan 22 13:32:20 2025 +0800 Set chart height to 1 (#32987) commitee9931afd3Author: Jordi Enric <37541088+jordienr@users.noreply.github.com> Date: Tue Jan 21 18:01:16 2025 +0100 service status: hide info footer if all services OK (#32966) hide if all services are operational commitb5437c630eAuthor: Ivan Vasilov <vasilov.ivan@gmail.com> Date: Tue Jan 21 17:45:06 2025 +0100 feat: Add a banner for clock skew in studio (#32866) * Add a ClockSkewBanner on top of studio. * Fix the color of the RestrictionBanner. * Add an API endpoint which return the current UTC time on the server. * Fix the glob pattern for docs in turbo.json. * Force docs to build. * Revert unneeded changes. * Add feature flag for clock skew banner. * Add a comment. commit3f5e586995Author: Joshen Lim <joshenlimek@gmail.com> Date: Wed Jan 22 00:28:21 2025 +0800 Fix table editor selected row BG color (#32961) commitd9fbf14a81Author: Jordi Enric <37541088+jordienr@users.noreply.github.com> Date: Tue Jan 21 17:24:42 2025 +0100 Fix chart click (#32834) fix chart click commit3a9e575761Author: Jordi Enric <37541088+jordienr@users.noreply.github.com> Date: Tue Jan 21 17:11:39 2025 +0100 SQL Charts fixes (#32795) * add better empty states * fix crashes and edge cases * rm unnecessary empty state * move empty state outside chartpanel * validate Y axis before flip to prevent crash * fix flip * disable btn instead of toast * fix types in canFlip * Update tooltip --------- Co-authored-by: Joshen Lim <joshenlimek@gmail.com> commit3440dc9c95Author: Joshen Lim <joshenlimek@gmail.com> Date: Tue Jan 21 20:56:13 2025 +0800 Feat/reports v2/standardize block design (#32936) * Standardize block designs * Clean up * Add warning threshold colors for infra-monitoring stats * Address all other comments * Swap create custom report to use PUT commitfb569f9a13Author: Alaister Young <alaister@users.noreply.github.com> Date: Tue Jan 21 20:39:41 2025 +0800 fix: local storage test mocks (#32957) commit7a73817316Author: Alaister Young <alaister@users.noreply.github.com> Date: Tue Jan 21 20:25:56 2025 +0800 fix: sign users out if profile request 401s (#32955) * fix: sign users out if profile request 401s * remove console.log commit1f9af325c2Author: Bobbie Soedirgo <31685197+soedirgo@users.noreply.github.com> Date: Tue Jan 21 15:59:50 2025 +0800 docs: add example to order parent table by referenced table (#32920) * docs: add example to order parent table by referenced table * docs: more ordering by referenced table examples commit473c4a5639Author: Alaister Young <alaister@users.noreply.github.com> Date: Tue Jan 21 12:51:11 2025 +0800 chore: skip invalidation on sql only changes (#32934) commit29d72b6249Author: Alaister Young <alaister@users.noreply.github.com> Date: Tue Jan 21 12:07:18 2025 +0800 fix: remove duplicate archive function from pgmq_public (#32942) remove duplicate archive function commit78dee45ae4Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon Jan 20 21:49:07 2025 -0500 chore(deps): bump katex from 0.16.10 to 0.16.21 (#32876) Bumps [katex](https://github.com/KaTeX/KaTeX) from 0.16.10 to 0.16.21. - [Release notes](https://github.com/KaTeX/KaTeX/releases) - [Changelog](https://github.com/KaTeX/KaTeX/blob/main/CHANGELOG.md) - [Commits](https://github.com/KaTeX/KaTeX/compare/v0.16.10...v0.16.21) --- updated-dependencies: - dependency-name: katex dependency-type: direct:production ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> commit52735e38bfAuthor: Ivan Vasilov <vasilov.ivan@gmail.com> Date: Mon Jan 20 22:23:45 2025 +0100 chore: Rename all uses of `Tooltip_Shadcn_` to just `Tooltip` (#32860) * Rename all uses of Tooltip_Shadcn_ to just Tooltip. * Fix a leftover change. commit616edd8b5eAuthor: Ivan Vasilov <vasilov.ivan@gmail.com> Date: Mon Jan 20 22:04:05 2025 +0100 chore: Fix the turbo tasks for `docs` app (#32941) * Separate turbo config for docs app into its own separate file. Add a task dependency for codegen tasks. * Fix the clean command. Remove the prebuild command cause it's already covered by turbo. commit5e12593262Author: Han Qiao <sweatybridge@gmail.com> Date: Mon Jan 20 23:45:35 2025 +0800 Update branching docs to mention vercel connection (#32939) commitd1bf79838aAuthor: RampantDespair <63611551+RampantDespair@users.noreply.github.com> Date: Mon Jan 20 09:29:03 2025 -0500 chore: refactor docker-compose.yml unify syntax style (#32668) * Update docker-compose.yml * Moved SECRET_KEY_BASE and VAULT_ENC_KEY to .env commit51d4f053dbAuthor: Nicolas <nicolascamara29@gmail.com> Date: Mon Jan 20 11:11:20 2025 -0300 fix(dashboard): Fixed broken link in the 'secure foreign table' popover (#31855) dashboard: fix broken link commitd139a8f0edAuthor: Joshen Lim <joshenlimek@gmail.com> Date: Mon Jan 20 21:27:54 2025 +0800 Swap CALL to SELECT for database functions in cron jobs (#32927) commit31da214451Author: Andrew Valleteau <avallete@users.noreply.github.com> Date: Mon Jan 20 21:09:49 2025 +0900 chore(docs): update custom db settings docs (#32853) commit78f7a0439aAuthor: Francesco Sansalvadore <f.sansalvadore@gmail.com> Date: Mon Jan 20 10:34:35 2025 +0100 Fix: mobile styling bugs (#32931) * fix project card height * fix panel notice commit1983f50433Author: Bobbie Soedirgo <31685197+soedirgo@users.noreply.github.com> Date: Mon Jan 20 16:30:35 2025 +0800 chore: vault -> supabase_vault (#32647) commit0a3df2296eAuthor: Jordi Enric <37541088+jordienr@users.noreply.github.com> Date: Mon Jan 20 09:26:22 2025 +0100 keep polling til all services are healthy (#32794) * keep polling til all services are healthy * fix type errs * use loader in coming up icon * consistent icons commit0129c94cf1Author: Joshen Lim <joshenlimek@gmail.com> Date: Mon Jan 20 15:49:32 2025 +0800 ReportsV2 P2: Support adding SQL snippets to Reports (#32851) * midway * Render, save, and save configuration of SQL blocks * Fix re ordering of blocks not showing save UI * Remove console log * Smol fix * Add queryHeight param to queryBlock * Reinstate telemetry for run query clicked from assistant * Add * Add resizing * Change compactType * Fix switching reports doesnt update * ONly show date picker if theres a chart thats using daily stats or infra monitoring * Fix client crash * Smol update commitd9a7b43cacAuthor: Joshen Lim <joshenlimek@gmail.com> Date: Mon Jan 20 14:33:53 2025 +0800 Chore/fix cron job card (#32767) * Add copy action to cron job card command * Fix * Remove unused code * Refactor the cron job parsing. Expanded some of the existing tests. Added more tests. * The last run data can be undefined if the cron was just created. The data for caching in RQ can't be undefined so it's forced to null. * Test whether the edge function points to its own project. If not, parse it as a HTTP request. * Use toStrictEqual instead of toMatchObject for more correct tests. * Add min height to the codeblock, the copy button was obscured if the code was a one-liner. * Add snippet to all types of cron jobs. Automatically update it when the form changes. * Minor fixes. --------- Co-authored-by: Ivan Vasilov <vasilov.ivan@gmail.com> commit9f9b2be262Author: Joshen Lim <joshenlimek@gmail.com> Date: Mon Jan 20 14:13:09 2025 +0800 Assistant chat check keycode enter (#32898) commitc5d664d214Author: Alaister Young <alaister@users.noreply.github.com> Date: Mon Jan 20 14:03:28 2025 +0800 fix: don't retry queries on 4xx errors (#32923) commit347dbcc875Author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon Jan 20 05:18:11 2025 +0000 feat: update mgmt api docs (#32918) Co-authored-by: phamhieu <689843+phamhieu@users.noreply.github.com> Co-authored-by: Bobbie Soedirgo <31685197+soedirgo@users.noreply.github.com> commit8acc80ec38Author: Pamela Chia <pamelachiamayyee@gmail.com> Date: Mon Jan 20 12:14:22 2025 +0800 feat: pro benefit wording test (#32862) commit9d534c9f5aAuthor: Alaister Young <alaister@users.noreply.github.com> Date: Mon Jan 20 11:27:38 2025 +0800 fix: response error codes (#30581) * fix: response error codes * upgrade docs * remove request url modification middleware * move api routes for self-hosted to platform folder * remove some lib/common/fetch usage * docs: use middleware for openapi-fetch (#30600) Get rid of the unauthedAllowedPost function (I don't think there's any harm in letting any requests that require authentication to just 403, they should be disabled at the React Query level and if not they will fail gracefully enough...) * fix local count query * add default values for clone mutation * fix ts and codegen * add missing lodash dep to playwright tests * Fix the playwright tests to match the new folder structure for selfhosted variant. * remove unused import * Remove unused state * remove unused sql debug mutation * remove unused export * fix notifications query * fix jwt updating status * fix typescript * save sql snippet after renaming * update codegen & fix ts error * override array querySerializer --------- Co-authored-by: Charis <26616127+charislam@users.noreply.github.com> Co-authored-by: Joshen Lim <joshenlimek@gmail.com> Co-authored-by: Ivan Vasilov <vasilov.ivan@gmail.com> commitbd0e979f8cAuthor: Charis <26616127+charislam@users.noreply.github.com> Date: Sat Jan 18 11:31:40 2025 -0500 fix: search index upload (#32904) Search index pipeline shouldn't be trying to read troubleshooting section yet (those are still searched via GH discussions). Trying to read it errors as they don't have the same frontmatter shape as other guides content. commit2b9d796a2bAuthor: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Date: Sat Jan 18 01:54:43 2025 +0000 [bot] sync troubleshooting guides to db (#32895) Co-authored-by: github-docs-sync-bot <github-docs-sync-bot@supabase.com> commit25e376a8b1Author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Date: Sat Jan 18 01:53:33 2025 +0000 [bot] fix lint errors (#32894) Co-authored-by: github-docs-bot <github-docs-bot@supabase.com> commitd1281dad91Author: Charis <26616127+charislam@users.noreply.github.com> Date: Fri Jan 17 20:47:48 2025 -0500 migrate(docs): troubleshooting 16 (#30953) * migrate(docs): troubleshooting 16 db performance, configuration * Update how-long-does-it-take-to-restore-a-database-from-a-point-in-time-backup-pitr-qO8gOG.mdx Added keywords for PITR restore article * Apply suggestions from code review --------- Co-authored-by: Kevin Brolly <kevin.brolly@supabase.io> commit9742de2ab2Author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Date: Sat Jan 18 01:45:26 2025 +0000 [bot] fix lint errors (#32892) Co-authored-by: github-docs-bot <github-docs-bot@supabase.com> commitc2ece15f22Author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Date: Sat Jan 18 01:36:49 2025 +0000 [bot] sync troubleshooting guides to db (#32893) Co-authored-by: github-docs-sync-bot <github-docs-sync-bot@supabase.com> commit7837deee41Author: Charis <26616127+charislam@users.noreply.github.com> Date: Fri Jan 17 20:30:04 2025 -0500 migrate(docs): troubleshooting 12 (#30942) * migrate(docs): troubleshooting 12 database connections * Update database-error-remaining-connection-slots-are-reserved-for-non-replication-superuser-connections-3V3nIb.mdx * Update how-do-i-update-connection-pool-settings-in-my-dashboard-wAxTJ_.mdx Added missing content * Apply suggestions from code review --------- Co-authored-by: Kevin Brolly <kevin.brolly@supabase.io> commita9ed0b4a66Author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Date: Sat Jan 18 01:12:34 2025 +0000 [bot] fix lint errors (#32890) Co-authored-by: github-docs-bot <github-docs-bot@supabase.com> commit6687baa3e8Author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Date: Sat Jan 18 01:04:38 2025 +0000 [bot] sync troubleshooting guides to db (#32891) Co-authored-by: github-docs-sync-bot <github-docs-sync-bot@supabase.com> commitc8b9615b34Author: Charis <26616127+charislam@users.noreply.github.com> Date: Fri Jan 17 19:58:07 2025 -0500 migrate(docs): troubleshooting 13 (#30941) * migrate(docs): troubleshooting 13 dashboard * Update apps/docs/content/troubleshooting/dashboard-errors-when-managing-users-N1ls4A.mdx Co-authored-by: Charis <26616127+charislam@users.noreply.github.com> * Apply suggestions from code review Co-authored-by: Charis <26616127+charislam@users.noreply.github.com> * Apply suggestions from code review --------- Co-authored-by: Kevin Brolly <kevin.brolly@supabase.io> commitd60410be39Author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Date: Sat Jan 18 00:51:37 2025 +0000 [bot] fix lint errors (#32888) Co-authored-by: github-docs-bot <github-docs-bot@supabase.com> commitbc67f46cf4Author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Date: Sat Jan 18 00:42:54 2025 +0000 [bot] sync troubleshooting guides to db (#32889) Co-authored-by: github-docs-sync-bot <github-docs-sync-bot@supabase.com> commitf2c354ef62Author: Charis <26616127+charislam@users.noreply.github.com> Date: Fri Jan 17 19:36:45 2025 -0500 migrate(docs): troubleshooting 5 (#30943) * migrate(docs): troubleshooting 5 logs, error messages * Delete apps/docs/content/troubleshooting/advanced-filtering-in-the-log-explorer-IJsGQq.mdx | redundant * Apply suggestions from code review * format --------- Co-authored-by: TheOtherBrian1 <91111415+TheOtherBrian1@users.noreply.github.com> commit3fc9dc8dd4Author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Date: Sat Jan 18 00:06:02 2025 +0000 [bot] sync troubleshooting guides to db (#32887) Co-authored-by: github-docs-sync-bot <github-docs-sync-bot@supabase.com> commit929c3c7b4cAuthor: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri Jan 17 19:00:11 2025 -0500 [bot] fix lint errors (#32885) * [bot] fix lint errors * Apply suggestions from code review --------- Co-authored-by: github-docs-bot <github-docs-bot@supabase.com> Co-authored-by: Charis <26616127+charislam@users.noreply.github.com> commitb90467581eAuthor: Charis <26616127+charislam@users.noreply.github.com> Date: Fri Jan 17 18:48:14 2025 -0500 migrate(docs): troubleshooting 14 (#30944) * migrate(docs): troubleshooting 14 rls, supavisor, connections * Update do-i-need-to-expose-security-definer-functions-in-row-level-security-policies-iI0uOw.mdx * Update rls-simplified-BJTcS8.mdx * Apply suggestions from code review * format --------- Co-authored-by: TheOtherBrian1 <91111415+TheOtherBrian1@users.noreply.github.com> commit3723f7cd84Author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri Jan 17 23:31:02 2025 +0000 [bot] fix lint errors (#32883) Co-authored-by: github-docs-bot <github-docs-bot@supabase.com> commit04ff5fe1ebAuthor: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri Jan 17 23:24:29 2025 +0000 [bot] sync troubleshooting guides to db (#32884) Co-authored-by: github-docs-sync-bot <github-docs-sync-bot@supabase.com> commit5ff657a349Author: Charis <26616127+charislam@users.noreply.github.com> Date: Fri Jan 17 18:17:25 2025 -0500 migrate(docs): troubleshooting 19 (#30945) * migrate(docs): troubleshooting 19 grafana, metrics * Update grafana-not-displaying-data-sXJrMj.mdx * Update grafana-not-displaying-data-sXJrMj.mdx * Update how-to-view-database-metrics-uqf2z_.mdx * Update interpreting-supabase-grafana-io-charts-MUynDR.mdx * added keywords * Apply suggestions from code review --------- Co-authored-by: TheOtherBrian1 <91111415+TheOtherBrian1@users.noreply.github.com> commit7f4cf359f3Author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri Jan 17 22:58:25 2025 +0000 [bot] sync troubleshooting guides to db (#32881) Co-authored-by: github-docs-sync-bot <github-docs-sync-bot@supabase.com> Co-authored-by: Charis <26616127+charislam@users.noreply.github.com> commit3d45ae3ce9Author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri Jan 17 22:29:31 2025 +0000 [bot] sync troubleshooting guides to db (#32882) Co-authored-by: github-docs-sync-bot <github-docs-sync-bot@supabase.com> commita950511e04Author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri Jan 17 22:23:15 2025 +0000 [bot] fix lint errors (#32880) Co-authored-by: github-docs-bot <github-docs-bot@supabase.com> commitb79f05df90Author: Charis <26616127+charislam@users.noreply.github.com> Date: Fri Jan 17 17:17:10 2025 -0500 migrate(docs): troubleshooting 23 (#30946) * migrate(docs): troubleshooting 23 postgres performance * Update how-postgres-chooses-which-index-to-use-_JHrf4.mdx * Update memory-and-swap-usage-explained-aPNgm0.mdx --------- Co-authored-by: TheOtherBrian1 <91111415+TheOtherBrian1@users.noreply.github.com> commitb25ae29d1bAuthor: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri Jan 17 22:13:20 2025 +0000 [bot] fix lint errors (#32878) Co-authored-by: github-docs-bot <github-docs-bot@supabase.com> commit2e77d09960Author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri Jan 17 22:07:11 2025 +0000 [bot] sync troubleshooting guides to db (#32879) Co-authored-by: github-docs-sync-bot <github-docs-sync-bot@supabase.com> commit6312618932Author: Charis <26616127+charislam@users.noreply.github.com> Date: Fri Jan 17 16:49:23 2025 -0500 migrate(docs): troubleshooting 7 (#30936) auth commita42e17d0a9Author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri Jan 17 21:43:43 2025 +0000 [bot] sync troubleshooting guides to db (#32874) Co-authored-by: github-docs-sync-bot <github-docs-sync-bot@supabase.com> commit0e60b508f6Author: Charis <26616127+charislam@users.noreply.github.com> Date: Fri Jan 17 15:52:45 2025 -0500 migrate(docs): troubleshooting 6 (#30935) * migrate(docs): troubleshooting 6 auth * Apply suggestions from code review commit53a8a94a72Author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri Jan 17 20:26:53 2025 +0000 [bot] fix lint errors (#32872) Co-authored-by: github-docs-bot <github-docs-bot@supabase.com> commit8a96b53c64Author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri Jan 17 20:20:14 2025 +0000 [bot] sync troubleshooting guides to db (#32873) Co-authored-by: github-docs-sync-bot <github-docs-sync-bot@supabase.com> commit8deced7dabAuthor: Charis <26616127+charislam@users.noreply.github.com> Date: Fri Jan 17 15:00:40 2025 -0500 migrate(docs): troubleshooting 9 (#30937) * migrate(docs): troubleshooting 9 timeouts, latency * light updates * Update NavigationMenu.constants.ts * Update canceling-statement-due-to-statement-timeout-581wFv.mdx Added keyword * Apply suggestions from code review --------- Co-authored-by: Brian Brennglass <brian@Brians-MacBook-Pro.local> Co-authored-by: TheOtherBrian1 <91111415+TheOtherBrian1@users.noreply.github.com> Co-authored-by: Kevin Brolly <kevin.brolly@supabase.io> commitf705b7da60Author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri Jan 17 19:15:30 2025 +0000 [bot] sync troubleshooting guides to db (#32871) Co-authored-by: github-docs-sync-bot <github-docs-sync-bot@supabase.com> commit7b1c4e09aeAuthor: Charis <26616127+charislam@users.noreply.github.com> Date: Fri Jan 17 14:08:53 2025 -0500 migrate(docs): troubleshooting 10 (#30938) * migrate(docs): troubleshooting 10 misc database * Apply suggestions from code review commitf2ae79e887Author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri Jan 17 19:02:14 2025 +0000 [bot] fix lint errors (#32869) Co-authored-by: github-docs-bot <github-docs-bot@supabase.com> commit4bd7e9e64fAuthor: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri Jan 17 18:56:49 2025 +0000 [bot] sync troubleshooting guides to db (#32870) Co-authored-by: github-docs-sync-bot <github-docs-sync-bot@supabase.com> commit25306236eaAuthor: Charis <26616127+charislam@users.noreply.github.com> Date: Fri Jan 17 13:49:47 2025 -0500 migrate(docs): troubleshooting 8 (#30939) * migrate(docs): troubleshooting 8 auth * Apply suggestions from code review commitbefb7a9b3cAuthor: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri Jan 17 18:29:47 2025 +0000 [bot] sync troubleshooting guides to db (#32867) Co-authored-by: github-docs-sync-bot <github-docs-sync-bot@supabase.com> commitecd181bcd9Author: Francesco Sansalvadore <f.sansalvadore@gmail.com> Date: Fri Jan 17 19:07:35 2025 +0100 studio mobile v2 (#32630) * improve some studio mobile layouts * improve some studio mobile layouts * improve settings * assistant mobile * assistant mobile * assistant mobile * responsive formlayout and new project layout * improve dashboard pages headers * improve dashboard auth pages * mobile org settings * mobile billing fixes * adjust paused project container height * remove comments * triggers * leftovers * ai assistant * fix errors * remove 16px input size * fix test * merge access tokens settings page conflicsts * smol integrations here and there commit68f0efcdadAuthor: Charis <26616127+charislam@users.noreply.github.com> Date: Fri Jan 17 12:57:47 2025 -0500 migrate(docs): troubleshooting 11 (#30940) * migrate(docs): troubleshooting 11 account and org management * Update check-usage-for-monthly-active-users-mau-MwZaBs.mdx Added Keywords * Update converted-github-account-to-organisation---lost-supabase-account-access-5wsE_1.mdx Changed spelling of organization --------- Co-authored-by: Kevin Brolly <kevin.brolly@supabase.io> commitf2c7e35c23Author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri Jan 17 12:55:40 2025 -0500 [bot] fix lint errors (#32846) * [bot] fix lint errors * add capitalization exceptions * Apply suggestions from code review --------- Co-authored-by: github-docs-bot <github-docs-bot@supabase.com> Co-authored-by: Charis <26616127+charislam@users.noreply.github.com> commit84311e7d09Author: Ivan Vasilov <vasilov.ivan@gmail.com> Date: Fri Jan 17 11:08:14 2025 +0100 chore: Fix the env vars for turbo (#31104) * Check all env vars for studio and list them properly in turbo.json. * Check all env vars for design-system. * Fix all env vars for www. * Fix all env vars for docs. * Add the rest of the env vars from the packages folder. * Revert the changes in the sign-in pages. * Remove useless files. Fix a comment. * Fix the links in extensions page to always point to supabase.com/docs. * Change the feature flag rewrite in studio to point to supabase.com/.flags endpoint. * Replace NEXT_PUBLIC_VERCEL_URL with NEXT_PUBLIC_VERCEL_BRANCH_URL because it's more stable on vercel.com. Remove it from apps where it's not needed. * Add env vars from packages. Move all passthrough env vars to env vars since they're stable (don't change between pushes). * Revert changes of studio files. * Minor fixes for the merge commit. * Replace all uses of SITE_URL with LW_URL (they're the same). SITE_ORIGIN is not constructed from env vars. LW_URL is constructed from SITE_ORIGIN and launch_week string. * Use SITE_ORIGIN when fetching the ticket-og. commit8aa5523fccAuthor: Ivan Vasilov <vasilov.ivan@gmail.com> Date: Fri Jan 17 10:54:02 2025 +0100 chore: Migrate tooltips in studio to use shadcn tooltips (#32679) * Remove radix-popover and radix-tooltip as deps from studio. * Migrate all uses of tooltip to shadcn tooltips. * Add tooltip portal to all shadcn tooltips. * Fix a warning about MenuItem not accepting refs in StorageMenu. * Remove unneeded styling for the tooltips. * Set a default delay duration for all tooltips in Studio. * Fix a type error. * Check and fix all tooltips. commit67cbbaacf2Author: Ivan Vasilov <vasilov.ivan@gmail.com> Date: Fri Jan 17 10:52:46 2025 +0100 fix: Unify the design for account pages (#30891) Refactor all account pages to use ScaffoldContainer and have the same design. commitca8ad52188Author: Saxon Fletcher <saxonafletcher@gmail.com> Date: Fri Jan 17 19:50:16 2025 +1000 AI Assistant Performance (#32792) commit4278bd4ec1Author: Kang Ming <kang.ming1996@gmail.com> Date: Thu Jan 16 22:54:21 2025 -0800 fix: bump auth-js version to v2.67.3 (#31217) * fix: bump auth-js version to v2.67.3 * chore: add supabase/auth and supabase/dashboard as codeowners * Revert "chore: add supabase/auth and supabase/dashboard as codeowners" This reverts commit57fc5776ba. * bump supabase-js version * import user type from single gotrue * fix auth-js version in studio * remove auth-js dep in studio * fix ts * use catalog versions * fix ts * Bump realtime-js version to avoid having 2 versions. * Add @supabase/realtime-js to the pnpm catalog. * upgrade realtime-js --------- Co-authored-by: Alaister Young <a@alaisteryoung.com> Co-authored-by: Ivan Vasilov <vasilov.ivan@gmail.com> commit7ce0038156Author: Andrew Valleteau <avallete@users.noreply.github.com> Date: Fri Jan 17 15:33:15 2025 +0900 chore(docs): add dotenvx example (#31213) * wip * wip * wip * remove seeds * wip * add branching memento * remove triple dots * proofread * chore: mention direct secret usage * chore: update README.md * chore: update docs * fix: .env.local to .env.developemnt * chore: fix typo * chore: fix commands * chore: update README.md * chore: apply PR comments * chore: rename .env.local to .env * chore: simplify dotenvx setup (#32824) * chore: bump cli * chore: disable unused seed --------- Co-authored-by: Han Qiao <sweatybridge@gmail.com> Co-authored-by: Qiao Han <qiao@supabase.io> commit30a86fe0e8Author: Han Qiao <sweatybridge@gmail.com> Date: Fri Jan 17 13:37:56 2025 +0800 docs: clarify the implications of branches auto pausing (#32854) * Remote notice about pausing branches after inactivity * Update branching.mdx * Update branching.mdx * Update branching.mdx * Update branching.mdx commit8c3fd055faAuthor: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri Jan 17 00:28:57 2025 +0000 [bot] sync troubleshooting guides to db (#32847) Co-authored-by: github-docs-sync-bot <github-docs-sync-bot@supabase.com> commita0e144b1a2Author: Charis <26616127+charislam@users.noreply.github.com> Date: Thu Jan 16 19:19:11 2025 -0500 migrate(docs): troubleshooting 25 (#30948) supavisor, db clients commit05dfc56211Author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu Jan 16 19:17:17 2025 -0500 [bot] sync troubleshooting guides to db (#32845) Co-authored-by: github-docs-sync-bot <github-docs-sync-bot@supabase.com> commit42efba186bAuthor: Charis <26616127+charislam@users.noreply.github.com> Date: Thu Jan 16 19:10:00 2025 -0500 migrate(docs): troubleshooting 24 (#30947) * migrate(docs): troubleshooting 24 nextjs, edge functions * Apply suggestions from code review commitd633ced97dAuthor: Saxon Fletcher <saxonafletcher@gmail.com> Date: Fri Jan 17 09:59:21 2025 +1000 Feat/new project creation experiment (#31237) * some early ideas * better approach * fix globe stuff * add initial step * reset and submit button for chat * cleanup * remove www * more clean up * mobile and more cleanup * fixes * update advanced and security * fix project checks * connect form * fix reset and tidied up other things * add layout options * a/b test * add offset * add ab test * remove www packages * remove www * package * update coordinates * feat: create ProjectCreationInitialStepSubmittedEvent * feat: add event for capturing intention of prompting * fix: bring pnpm-lock up to date * fix ts errors * fix globe * fix globe animation * fix ts * remove imports and tools * update module resolution * global redirect * delay rendering * Update apps/studio/pages/new/[slug].tsx Co-authored-by: Alaister Young <alaister@users.noreply.github.com> * take directly to v2 via project create dropdown * move redirect to useEffect * feat: distinguish events between initial and second step * feat: emit an event when create project is clicked on new/v2 * fix: correct event type defs * remove unused imports * Various clean ups * improvements * Minor refactors * clean up * ts fixes --------- Co-authored-by: Long Hoang <1732217+loong@users.noreply.github.com> Co-authored-by: Alaister Young <alaister@users.noreply.github.com> Co-authored-by: Joshen Lim <joshenlimek@gmail.com> commita0e3ab86b0Author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu Jan 16 18:55:26 2025 -0500 [bot] fix lint errors (#32843) * [bot] fix lint errors * add exception * Apply suggestions from code review --------- Co-authored-by: github-docs-bot <github-docs-bot@supabase.com> Co-authored-by: Charis <26616127+charislam@users.noreply.github.com> commit7587d5048eAuthor: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu Jan 16 18:20:49 2025 -0500 [bot] fix lint errors (#32784) Co-authored-by: github-docs-bot <github-docs-bot@supabase.com> commit840805672eAuthor: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu Jan 16 18:11:52 2025 -0500 [bot] sync troubleshooting guides to db (#32785) Co-authored-by: github-docs-sync-bot <github-docs-sync-bot@supabase.com> commit31e21d5518Author: Charis <26616127+charislam@users.noreply.github.com> Date: Thu Jan 16 14:00:17 2025 -0500 fix: troubleshooting sync script (#32806) Fix some issues with the script: - GraphQL query strings were built from template literals without escaping, leading to errors when sending to GitHub API, now added escaping - Lack of visibility when GitHub API errors because the actual errors array is buried below the expanded portion of the object output, now drilling down to the usable portion of the returned error - When the sync bot auto-adds the database ID, it also reformats the TOML frontmatter, which leads to a spurious "content changed" update when the checksums don't match in the next check run. Resolve this by normalizing the frontmatter before calculating the checksum. commitbf49d8ab7dAuthor: Ivan Vasilov <vasilov.ivan@gmail.com> Date: Thu Jan 16 18:54:06 2025 +0100 chore: Fix the local studio tests (#32836) * Set a fixed version of ubuntu for running the local studio tests. * Fix a possible yaml issue. * Revert to ubuntu-latest. Try bumping the playwright package. * Add init script to force the navigation menu to not expand. * Another try. * Extend the timeout. * Another try. * Try. * T. * T. * Revert some of the unneeded changes. commit16f950d615Author: Han Qiao <sweatybridge@gmail.com> Date: Fri Jan 17 00:27:26 2025 +0800 Update import-maps.mdx to document deno.json (#32830) * Update import-maps.mdx to document deno.json * Update import-maps.mdx * Update import-maps.mdx * Update import-maps.mdx * Run prettier commit80f4c61f2dAuthor: Etienne Stalmans <staaldraad@users.noreply.github.com> Date: Thu Jan 16 12:28:33 2025 +0100 fix: additional ingest hosts for sentry (#32825) Sentry has US and Europe ingest hosts (us, de). Allow these in CSP commit9ed9938fe0Author: Joshen Lim <joshenlimek@gmail.com> Date: Thu Jan 16 18:26:46 2025 +0800 Add log out route (#32820) commitcfb18eb272Author: Stojan Dimitrovski <sdimitrovski@gmail.com> Date: Thu Jan 16 10:53:02 2025 +0100 docs: add minimal jwt example with custom access token hook (#32770) commit77b76e399aAuthor: Kevin Grüneberg <k.grueneberg1994@gmail.com> Date: Thu Jan 16 14:32:18 2025 +0800 chore: remove react fiber (#32821) Unused, Alaister just added it after I removed it because his subconscious likes to see me suffer commit6b7f3c84a5Author: Kevin Grüneberg <k.grueneberg1994@gmail.com> Date: Thu Jan 16 14:15:40 2025 +0800 chore: bump stripe deps (#32819) Tested locally commitc5fd032a78Author: Han Qiao <sweatybridge@gmail.com> Date: Thu Jan 16 13:12:23 2025 +0800 chore: clarify supported file paths for static files (#32818) commite63a082ddaAuthor: Lakshan Perera <lakshan@supabase.io> Date: Thu Jan 16 09:55:31 2025 +1100 chore(docs): Added a guide on using wasm modules in Edge Functions (#32811) * chore(docs): Added a guide on using wasm modules in Edge Functions * update example * WASM -> Wasm * fix page title commitcdb95a6036Author: Lakshan Perera <lakshan@supabase.io> Date: Thu Jan 16 06:37:21 2025 +1100 chore: add an example for using wasm modules in Edge Functions (#32810) Co-authored-by: Rodrigo Mansueli <rodrigo@mansueli.com> commit9349d22360Author: Lakshan Perera <lakshan@supabase.io> Date: Thu Jan 16 06:30:32 2025 +1100 chore(docs): Added static_files to CLI config (#32801) commitf233c78794Author: Rodrigo Mansueli <rodrigo@mansueli.com> Date: Wed Jan 15 16:28:41 2025 -0300 Chore: update also last example on the page (#32809) commit3e94bc483cAuthor: Rodrigo Mansueli <rodrigo@mansueli.com> Date: Wed Jan 15 15:20:43 2025 -0300 Chore: update edge function example (#32808) Update auth.mdx commit592af2ffa2Author: Francesco Sansalvadore <f.sansalvadore@gmail.com> Date: Wed Jan 15 18:03:22 2025 +0100 feat: careers jobsCount in nav (#32771) * add jobsCount to careers nav * badge styling * mobile career counter * refactor static content generation * refactor * fix gh number formatting * remove comment * remove component * fix fresh local dev & update spacing commit8a648073deAuthor: Ivan Vasilov <vasilov.ivan@gmail.com> Date: Wed Jan 15 17:16:32 2025 +0100 chore: Remove unused published_at field from older blog posts (#32802) Remove unused published_at field from older blog posts. commit8e06301d36Author: Stojan Dimitrovski <sdimitrovski@gmail.com> Date: Wed Jan 15 14:43:18 2025 +0100 docs: remove private alpha docs from firebase tpa (#32797) commit462c3c8cfcAuthor: Jordi Enric <37541088+jordienr@users.noreply.github.com> Date: Wed Jan 15 11:42:06 2025 +0100 status check (#30204) commit265b4cddd7Author: Jordi Enric <37541088+jordienr@users.noreply.github.com> Date: Wed Jan 15 10:22:57 2025 +0100 SQL Chart fixes (#32769) * add labels * fix labels, hope to fix Y axis issue * Tiny fix * Make ChartConfig y scrollable * Only show flip CTA if values are all numerical * revert hiding flip button --------- Co-authored-by: Joshen Lim <joshenlimek@gmail.com> commita2aa5bc83dAuthor: Jordi Enric <37541088+jordienr@users.noreply.github.com> Date: Wed Jan 15 10:22:13 2025 +0100 feature: Adds logs chart with stacked charts with total errors (#32742) * add logschart with stacked bars * use ui charts pkg * fix contrast * move to ui-patterns * undo areachart * add recharts peerDep * update pckgjson and lock w recharts * feat: enable client-side rendering for LogsBarChart component * fix registry commitc7ebd91740Author: Alaister Young <alaister@users.noreply.github.com> Date: Wed Jan 15 16:42:50 2025 +0800 Revert "Temp disable count query" (#32788) * Revert "Temp disable count query (#31256)" This reverts commit05e06673b4. * update to use new api * only include params if they're not undefined commit0710d62665Author: Joshen Lim <joshenlimek@gmail.com> Date: Wed Jan 15 13:08:26 2025 +0800 ReportsV2 P1: Add Query block component (#32738) * Create QueryBlock component which will be a shared component used in AI Assistant and Reports * Deprecate AIAssistantPanel/SqlSnippet.ts * Fix user messages not getting persisted, only assistant messages * Add loading state to for query results in QueryBlock + hide block view configuration if query block is not chart * Address feedback * Fix TS * fix double border --------- Co-authored-by: Saxon Fletcher <saxonafletcher@gmail.com> commite420a48826Author: Joshen Lim <joshenlimek@gmail.com> Date: Wed Jan 15 12:21:13 2025 +0800 Check for profile in projects, organizations and permissions query (#32759) * Check for profile in projects, organizations and permissions query * Remove unused telemetry function commit15dfe1df8cAuthor: Joshen Lim <joshenlimek@gmail.com> Date: Wed Jan 15 11:56:58 2025 +0800 Fix vault missing exts alert (#32768) * Fix vault missing exts alert * Add minimum version prop commit935c33621dAuthor: Charis <26616127+charislam@users.noreply.github.com> Date: Tue Jan 14 20:46:17 2025 -0500 migrate(docs): troubleshooting 27 (#30949) * migrate(docs): troubleshooting 27 misc database * Apply suggestions from code review commit7924b32137Author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed Jan 15 00:04:06 2025 +0000 [bot] sync troubleshooting guides to db (#32781) Co-authored-by: github-docs-sync-bot <github-docs-sync-bot@supabase.com> commit65815efb64Author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed Jan 15 00:01:38 2025 +0000 [bot] fix lint errors (#32780) Co-authored-by: github-docs-bot <github-docs-bot@supabase.com> commit000cabd1ddAuthor: Charis <26616127+charislam@users.noreply.github.com> Date: Tue Jan 14 18:55:02 2025 -0500 migrate(docs): troubleshooting 29 (#30950) * migrate(docs): troubleshooting 29 misc database * Apply suggestions from code review * Update apps/docs/content/troubleshooting/resolving-database-hostname-and-managing-your-ip-address-pVlwE0.mdx commitb21094cac0Author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue Jan 14 23:49:18 2025 +0000 [bot] sync troubleshooting guides to db (#32779) Co-authored-by: github-docs-sync-bot <github-docs-sync-bot@supabase.com> commitf4818474ecAuthor: Charis <26616127+charislam@users.noreply.github.com> Date: Tue Jan 14 18:42:31 2025 -0500 migrate(docs): troubleshooting 31 (#30952) * migrate(docs): troubleshooting 31 auth, service role * Apply suggestions from code review commit699f708b0cAuthor: Charis <26616127+charislam@users.noreply.github.com> Date: Tue Jan 14 18:38:21 2025 -0500 fix: make examples available for isr (#32610) The examples folder needs to be explicitly included in the Vercel Serverless bundle. Because it's at the root of the monorepo rather than being within the `app/docs` folder, we copy it over pre-build (and pre-dev). Test the examples/prompts fix by re-enabling revalidations on graphql pages. Added a temp version of the fetch function so we can gradually reenable and monitor Vercel error rates over time. commita5daf7cee4Author: Charis <26616127+charislam@users.noreply.github.com> Date: Tue Jan 14 18:21:17 2025 -0500 fix: troubleshooting sync workflow (#32778) Workflow was missed when updating to pnpm commitaf42c0eec4Author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue Jan 14 22:42:37 2025 +0000 [bot] fix lint errors (#32776) * [bot] fix lint errors * Update apps/docs/content/troubleshooting/are-all-features-available-in-self-hosted-supabase-THPcqw.mdx --------- Co-authored-by: github-docs-bot <github-docs-bot@supabase.com> Co-authored-by: Charis <26616127+charislam@users.noreply.github.com> commit5690a61bfdAuthor: Charis <26616127+charislam@users.noreply.github.com> Date: Tue Jan 14 17:13:35 2025 -0500 migrate(docs): troubleshooting 4 (#30954) * migrate(docs): troubleshooting 4 self-hosting, local dev * Delete apps/docs/content/troubleshooting/local-development-workflow-is-painfully-slow-eIaTBw.mdx Shouldnt be included * Update apps/docs/content/troubleshooting/are-all-features-available-in-self-hosted-supabase-THPcqw.mdx --------- Co-authored-by: Kevin Brolly <kevin.brolly@supabase.io> commita143d89050Author: Joshen Lim <joshenlimek@gmail.com> Date: Tue Jan 14 23:21:11 2025 +0800 Add set null cta in ForeignRowSelector (#32762) * Add set null cta in ForeignRowSelector * Update UI for foreign key input field in RowEditor commit44d3204b2fAuthor: Terry Sutton <saltcod@gmail.com> Date: Tue Jan 14 11:21:35 2025 -0330 Chore/fix set to now (#32749) * Reuse set to now logic * Ensure set to now cta is visible if column is not nullable * Minor refactor --------- Co-authored-by: Joshen Lim <joshenlimek@gmail.com> commit692244cc10Author: Jordi Enric <37541088+jordienr@users.noreply.github.com> Date: Tue Jan 14 15:45:04 2025 +0100 rm monitoring tunnel (#32763) * rm monitoring tunnel * undo formatting * format w prettier i guess * rm route * Add CSP rule for sentry events. --------- Co-authored-by: Ivan Vasilov <vasilov.ivan@gmail.com> commit53eaab0f71Author: Joshen Lim <joshenlimek@gmail.com> Date: Tue Jan 14 22:09:03 2025 +0800 Show all cron jobs even those with no names (#32765) commit614beac5d9Author: Copple <10214025+kiwicopple@users.noreply.github.com> Date: Tue Jan 14 21:21:49 2025 +1300 chore: update self-hosted image versions (#31184) * chore: update image versions for docker/docker-compose.yml * chore: update image versions for docker/docker-compose.yml * chore: update image versions for docker/docker-compose.yml commit8d1027f58bAuthor: Copple <10214025+kiwicopple@users.noreply.github.com> Date: Tue Jan 14 21:20:26 2025 +1300 chore: update cli reference doc (#32758) commit34424881a1Author: Oliver Rice <github@oliverrice.com> Date: Mon Jan 13 20:59:24 2025 -0600 Revert "Temporarily disable enabling of queues exposure via postgrest" (#32753) * Revert "Temporarily disable enabling of queues exposure via postgrest (#32699)" This reverts commit506fcf5da2. * bugfix: sequence permissions for pgmq_public * Update apps/studio/data/database-queues/database-queues-toggle-postgrest-mutation.ts * enable service role * Smol fix --------- Co-authored-by: Wen Bo Xie <5532241+w3b6x9@users.noreply.github.com> Co-authored-by: Joshen Lim <joshenlimek@gmail.com> commitd93c09b03aAuthor: Thor 雷神 Schaeff <5748289+thorwebdev@users.noreply.github.com> Date: Tue Jan 14 10:50:06 2025 +0800 Thor/fix hono example (#32736) * fix: hono example. * fix: hono quickstart. * chore: update numbered list. commitc388cbe9d2Author: Joshen Lim <joshenlimek@gmail.com> Date: Tue Jan 14 10:32:22 2025 +0800 Add disk autoscale configuration parameters in compute and disk settings (#32628) * Add disk autoscale configuration parameters in compute and disk settings * TS fix * Fix * Fixes based on comments * Address all feedbacks * Small tweak --------- Co-authored-by: Alaister Young <a@alaisteryoung.com> commit7a0871b9ceAuthor: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon Jan 13 19:10:31 2025 +0000 feat: update mgmt api docs (#32732) Co-authored-by: phamhieu <689843+phamhieu@users.noreply.github.com> commit1b3a1befa3Author: Joshen Lim <joshenlimek@gmail.com> Date: Mon Jan 13 23:48:08 2025 +0800 Use whitespace-pre in TextConfirmModal (#32748) commit559236dbd0Author: Joshen Lim <joshenlimek@gmail.com> Date: Mon Jan 13 23:29:28 2025 +0800 Chore/query performance fixes and improvements (#32747) * Show tab max value in seconds if > 1000ms * Fix incorrect sort option in initial state with no URL state * Fix trim of undefined in Query Performance when retrieving index commitef2ba4a1fcAuthor: Joshen Lim <joshenlimek@gmail.com> Date: Mon Jan 13 23:19:10 2025 +0800 Add null placeholder to RowEditor foreign key input field (#32744) commit6e0b0237f5Author: Ivan Vasilov <vasilov.ivan@gmail.com> Date: Mon Jan 13 14:01:03 2025 +0100 fix: Remove /members/invite API calls (#32707) Remove /invite API calls. commit5c969f973dAuthor: Joshen Lim <joshenlimek@gmail.com> Date: Mon Jan 13 19:22:35 2025 +0800 Fix view connection string (#32683) commit14d5a79203Author: Francesco Sansalvadore <f.sansalvadore@gmail.com> Date: Mon Jan 13 11:22:04 2025 +0100 Chore: add links to hidden www pages (#32658) * fix vector icon * add supasquad and community content program links to oss page * remove console log commit14ea7a608eAuthor: Kevin Grüneberg <k.grueneberg1994@gmail.com> Date: Mon Jan 13 18:20:51 2025 +0800 docs: credit balance top up / slight copy changes (#32737) commit39f0b5823dAuthor: hallidayo <22655069+Hallidayo@users.noreply.github.com> Date: Mon Jan 13 08:10:42 2025 +0000 deprecated: alerts - usage constant (#32661) switch to admonition commit4577389177Author: Alaister Young <alaister@users.noreply.github.com> Date: Mon Jan 13 13:08:50 2025 +0800 chore: send feature flags for page events (#32590) commit83c94206c2Author: Supun Sudaraka <ssudaraka@gmail.com> Date: Sun Jan 12 08:50:36 2025 +0530 docs: added google consent screen information to google oauth docs (#32703) * added google consent screen information to auth docs * updated the heading to be sentence case * Update apps/docs/content/guides/auth/social-login/auth-google.mdx Co-authored-by: Charis <26616127+charislam@users.noreply.github.com> --------- Co-authored-by: Charis <26616127+charislam@users.noreply.github.com> commitfc6be5284dAuthor: hoshima <hoshima@users.noreply.github.com> Date: Sat Jan 11 12:16:40 2025 +0900 docs: fix typo on quickstarts/hono (#32708) docs: fix quickstarts/hono commit506fcf5da2Author: Joshen Lim <joshenlimek@gmail.com> Date: Fri Jan 10 22:41:27 2025 +0800 Temporarily disable enabling of queues exposure via postgrest (#32699) commit0e930cf940Author: Jordi Enric <37541088+jordienr@users.noreply.github.com> Date: Fri Jan 10 13:21:53 2025 +0100 r2np: new cost (#32632) * add new cost estimate * fix api types * update api types * restore api.d.ts * fix types * fix utils * clean utils getComputeHourlyPrice --------- Co-authored-by: Ivan Vasilov <vasilov.ivan@gmail.com> commit2781fb9285Author: Joshen Lim <joshenlimek@gmail.com> Date: Fri Jan 10 16:28:26 2025 +0800 Only show Connect UI in layout header if project is active healthy (#32698) * Only show Connect UI and branching UI in layout header if project is active healthy * Only hide connect UI * Opt for disabled state with tooltip instead commitc791dd9e29Author: Kevin Grüneberg <k.grueneberg1994@gmail.com> Date: Fri Jan 10 10:20:35 2025 +0800 feat: credit top up (#32680) commit84694717e3Author: Wen Bo Xie <5532241+w3b6x9@users.noreply.github.com> Date: Thu Jan 9 13:26:50 2025 -0500 docs: add OpenAI Telemetry opt in permissions (#32667) commitb09bc40225Author: Joshen Lim <joshenlimek@gmail.com> Date: Thu Jan 9 23:20:52 2025 +0800 Remove extend your database header (#32686) commit3122efc7b7Author: Stojan Dimitrovski <sdimitrovski@gmail.com> Date: Thu Jan 9 13:27:02 2025 +0100 feat: make firebase tpa generally available (#32573) * feat: make firebase tpa generally available * Simplify the dropdown menu label. --------- Co-authored-by: Ivan Vasilov <vasilov.ivan@gmail.com> commit724f046170Author: Marc Köhler <74593656+Than-DE@users.noreply.github.com> Date: Thu Jan 9 12:47:14 2025 +0100 fix(studio): auth email hook sheet padding (#32569) commitab3a3b3c76Author: Ivan Vasilov <vasilov.ivan@gmail.com> Date: Thu Jan 9 12:36:32 2025 +0100 chore: Move playwright tests to tests/local-studio-tests (#21488) * Move the playwright package to tests folder. * Update the workspace list. * Change the name of the playwright tests to local studio tests. commit3d8c0246f5Author: Saxon Fletcher <saxonafletcher@gmail.com> Date: Thu Jan 9 20:30:37 2025 +1000 add assistant to advisor (#32665) * add assistant to advisor * Fix the cursor on the last line to not end in the middle of the textbox. --------- Co-authored-by: Ivan Vasilov <vasilov.ivan@gmail.com> commit9d6cf3ee51Author: Joshen Lim <joshenlimek@gmail.com> Date: Thu Jan 9 18:06:31 2025 +0800 Add contextual invalidation in SQL Editor (#32675) commiteb867734fbAuthor: Joshen Lim <joshenlimek@gmail.com> Date: Thu Jan 9 16:39:27 2025 +0800 Show MFA warning when field is updated, not until the form is saved (#32673) commiteb42b2c241Author: Joshen Lim <joshenlimek@gmail.com> Date: Thu Jan 9 10:55:14 2025 +0800 Persist last selected database only for sql editor via local storage (#32598) * Persist last selected database only for sql editor via local storage * Add missing useEffect commit3d4cd89a64Author: Charis <26616127+charislam@users.noreply.github.com> Date: Wed Jan 8 18:54:09 2025 -0500 fix: remix pkce example (#32662) commit98d914d1fbAuthor: Ivan Vasilov <vasilov.ivan@gmail.com> Date: Wed Jan 8 21:30:15 2025 +0100 fix: Fix the referer for Posthog (#32656) Fix the referer for posthog. commit11caf61f43Author: Ivan Vasilov <vasilov.ivan@gmail.com> Date: Wed Jan 8 21:29:45 2025 +0100 chore: Delete the `tests` package (#32527) * Remove the tests package. * Remove all workspace configs for the tests package. commit900b4bbad6Author: Charis <26616127+charislam@users.noreply.github.com> Date: Wed Jan 8 15:08:45 2025 -0500 fix: swift ref docs filter params (#32633) Parameters given for `filter` function of Swift SDK don't match actual implementation. Documented as enum, implementation uses string. commit2d2ab28fc9Author: stepan <133258815+stpn48@users.noreply.github.com> Date: Wed Jan 8 17:42:12 2025 +0100 Fix theme toggle bug in footer (#32566) * fix: fix theme button overlap and hydration issues * fix: show sun icon when theme is light and moon when theme is dark * fix: use 'resolvedTheme' isntead of 'theme' to change icon when user has theme 'system' * refactor: use ternary operator commite326e41cefAuthor: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed Jan 8 13:41:12 2025 +0100 chore(deps): bump next from 14.2.15 to 14.2.21 (#32559) * chore(deps): bump next from 14.2.15 to 15.1.3 Bumps [next](https://github.com/vercel/next.js) from 14.2.15 to 15.1.3. - [Release notes](https://github.com/vercel/next.js/releases) - [Changelog](https://github.com/vercel/next.js/blob/canary/release.js) - [Commits](https://github.com/vercel/next.js/compare/v14.2.15...v15.1.3) --- updated-dependencies: - dependency-name: next dependency-type: direct:production ... Signed-off-by: dependabot[bot] <support@github.com> * Bump next to 14.2.21. --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Ivan Vasilov <vasilov.ivan@gmail.com> commit9b4b66b432Author: Francesco Sansalvadore <f.sansalvadore@gmail.com> Date: Wed Jan 8 12:13:42 2025 +0100 remove lw13 announcements (#32624) commit82bb29a16bAuthor: Jordi Enric <37541088+jordienr@users.noreply.github.com> Date: Wed Jan 8 12:11:59 2025 +0100 fix: branch dropdown sort & default branch shield (#32650) sort and add shield commit9eb3c22e99Author: Joshen Lim <joshenlimek@gmail.com> Date: Wed Jan 8 18:05:24 2025 +0700 Clean up storage s3 protocol settings dynamic rendering (#32601)
5676 lines
167 KiB
YAML
5676 lines
167 KiB
YAML
openref: 0.1
|
|
|
|
info:
|
|
id: reference/supabase-js
|
|
title: Supabase Client
|
|
description: |
|
|
|
|
Supabase JavaScript.
|
|
|
|
definition: ../../spec/enrichments/tsdoc_v2/combined.json
|
|
specUrl: https://github.com/supabase/supabase/edit/master/spec/supabase_js_v2.yml
|
|
slugPrefix: '/'
|
|
libraries:
|
|
- id: 'JavaScript'
|
|
version: '0.0.1'
|
|
|
|
functions:
|
|
- id: initializing
|
|
$ref: '@supabase/supabase-js.index.SupabaseClient.constructor'
|
|
description: |
|
|
You can initialize a new Supabase client using the `createClient()` method.
|
|
|
|
The Supabase client is your entrypoint to the rest of the Supabase functionality
|
|
and is the easiest way to interact with everything we offer within the Supabase ecosystem.
|
|
|
|
examples:
|
|
- id: create-client
|
|
name: createClient()
|
|
js: |
|
|
```js
|
|
import { createClient } from '@supabase/supabase-js'
|
|
|
|
// Create a single supabase client for interacting with your database
|
|
const supabase = createClient('https://xyzcompany.supabase.co', 'public-anon-key')
|
|
```
|
|
response: |
|
|
{
|
|
"hello":"world"
|
|
}
|
|
- id: with-additional-parameters
|
|
name: With additional parameters
|
|
js: |
|
|
```js
|
|
import { createClient } from '@supabase/supabase-js'
|
|
|
|
const options = {
|
|
db: {
|
|
schema: 'public',
|
|
},
|
|
auth: {
|
|
autoRefreshToken: true,
|
|
persistSession: true,
|
|
detectSessionInUrl: true
|
|
},
|
|
global: {
|
|
headers: { 'x-my-custom-header': 'my-app-name' },
|
|
},
|
|
}
|
|
const supabase = createClient("https://xyzcompany.supabase.co", "public-anon-key", options)
|
|
```
|
|
response: |
|
|
{
|
|
"hello":"jonny"
|
|
}
|
|
- id: api-schemas
|
|
name: API schemas
|
|
js: |
|
|
```js
|
|
import { createClient } from '@supabase/supabase-js'
|
|
|
|
// Provide a custom schema. Defaults to "public".
|
|
const supabase = createClient('https://xyzcompany.supabase.co', 'public-anon-key', {
|
|
db: { schema: 'other_schema' }
|
|
})
|
|
```
|
|
|
|
By default the API server points to the `public` schema. You can enable other database schemas within the Dashboard.
|
|
Go to `Settings > API > Schema` and add the schema which you want to expose to the API.
|
|
|
|
Note: each client connection can only access a single schema, so the code above can access the `other_schema` schema but cannot access the `public` schema.
|
|
- id: custom-fetch-implementation
|
|
name: Custom `fetch` implementation
|
|
js: |
|
|
```js
|
|
import { createClient } from '@supabase/supabase-js'
|
|
|
|
const supabase = createClient('https://xyzcompany.supabase.co', 'public-anon-key', {
|
|
global: { fetch: fetch.bind(globalThis) }
|
|
})
|
|
```
|
|
|
|
`supabase-js` uses the [`cross-fetch`](https://www.npmjs.com/package/cross-fetch) library to make HTTP requests,
|
|
but an alternative `fetch` implementation can be provided as an option.
|
|
This is most useful in environments where `cross-fetch` is not compatible (for instance Cloudflare Workers).
|
|
- id: react-native-options
|
|
name: React Native options
|
|
js: |
|
|
```js
|
|
import 'react-native-url-polyfill/auto'
|
|
import { createClient } from '@supabase/supabase-js'
|
|
import AsyncStorage from "@react-native-async-storage/async-storage";
|
|
|
|
const supabase = createClient("https://xyzcompany.supabase.co", "public-anon-key", {
|
|
auth: {
|
|
storage: AsyncStorage,
|
|
autoRefreshToken: true,
|
|
persistSession: true,
|
|
detectSessionInUrl: false,
|
|
},
|
|
});
|
|
```
|
|
|
|
For React Native we recommend using `AsyncStorage` as the storage implementation for Supabase Auth.
|
|
- id: auth.signUp()
|
|
title: 'signUp()'
|
|
$ref: '@supabase/gotrue-js.GoTrueClient.signUp'
|
|
notes: |
|
|
- By default, the user needs to verify their email address before logging in. To turn this off, disable **Confirm email** in [your project](https://supabase.com/dashboard/project/_/auth/providers).
|
|
- **Confirm email** determines if users need to confirm their email address after signing up.
|
|
- If **Confirm email** is enabled, a `user` is returned but `session` is null.
|
|
- If **Confirm email** is disabled, both a `user` and a `session` are returned.
|
|
- By default, when the user confirms their email address, they are redirected to the [`SITE_URL`](https://supabase.com/docs/guides/auth/redirect-urls). You can modify your `SITE_URL` or add additional redirect URLs in [your project](https://supabase.com/dashboard/project/_/auth/url-configuration).
|
|
- If signUp() is called for an existing confirmed user:
|
|
- When both **Confirm email** and **Confirm phone** (even when phone provider is disabled) are enabled in [your project](/dashboard/project/_/auth/providers), an obfuscated/fake user object is returned.
|
|
- When either **Confirm email** or **Confirm phone** (even when phone provider is disabled) is disabled, the error message, `User already registered` is returned.
|
|
- To fetch the currently logged-in user, refer to [`getUser()`](/docs/reference/javascript/auth-getuser).
|
|
examples:
|
|
- id: sign-up.
|
|
name: Sign up.
|
|
isSpotlight: true
|
|
js: |
|
|
```js
|
|
const { data, error } = await supabase.auth.signUp({
|
|
email: 'example@email.com',
|
|
password: 'example-password',
|
|
})
|
|
```
|
|
- id: sign-up-with-additional-user-metadata.
|
|
name: Sign up with additional user metadata.
|
|
isSpotlight: false
|
|
js: |
|
|
```js
|
|
const { data, error } = await supabase.auth.signUp(
|
|
{
|
|
email: 'example@email.com',
|
|
password: 'example-password',
|
|
options: {
|
|
data: {
|
|
first_name: 'John',
|
|
age: 27,
|
|
}
|
|
}
|
|
}
|
|
)
|
|
```
|
|
- id: auth.signInWithPassword()
|
|
title: 'signInWithPassword()'
|
|
$ref: '@supabase/gotrue-js.GoTrueClient.signInWithPassword'
|
|
notes: |
|
|
- Requires either an email and password or a phone number and password.
|
|
examples:
|
|
- id: sign-in-with-email-and-password
|
|
name: Sign in with email and password
|
|
isSpotlight: true
|
|
js: |
|
|
```js
|
|
const { data, error } = await supabase.auth.signInWithPassword({
|
|
email: 'example@email.com',
|
|
password: 'example-password',
|
|
})
|
|
```
|
|
- id: sign-in-with-phone-and-password
|
|
name: Sign in with phone and password
|
|
isSpotlight: false
|
|
js: |
|
|
```js
|
|
const { data, error } = await supabase.auth.signInWithPassword({
|
|
phone: '+13334445555',
|
|
password: 'some-password',
|
|
})
|
|
|
|
// After receiving a SMS with a OTP.
|
|
const { data, error } = await supabase.auth.verifyOtp({
|
|
phone: '+13334445555',
|
|
token: '123456',
|
|
})
|
|
```
|
|
- id: auth.signInWithOtp()
|
|
title: 'signInWithOtp()'
|
|
$ref: '@supabase/gotrue-js.GoTrueClient.signInWithOtp'
|
|
notes: |
|
|
- Requires either an email or phone number.
|
|
- This method is used for passwordless sign-ins where a OTP is sent to the user's email or phone number.
|
|
- If you're using an email, you can configure whether you want the user to receive a magiclink or a OTP.
|
|
- If you're using phone, you can configure whether you want the user to receive a OTP.
|
|
- The magic link's destination URL is determined by the [`SITE_URL`](https://supabase.com/docs/guides/auth/redirect-urls). You can modify the `SITE_URL` or add additional redirect URLs in [your project](https://supabase.com/dashboard/project/_/auth/url-configuration).
|
|
- If you are looking to send your own OTP emails, you can use the [Auth Admin command](https://supabase.com/docs/reference/javascript/auth-admin-generatelink) or the `Send Email` [Auth Hook](https://supabase.com/docs/guides/auth/auth-hooks)
|
|
examples:
|
|
- id: sign-in-with-email.
|
|
name: Sign in with email.
|
|
isSpotlight: true
|
|
description: The user will be sent an email which contains either a magiclink or a OTP or both. By default, a given user can only request a OTP once every 60 seconds.
|
|
js: |
|
|
```js
|
|
const { data, error } = await supabase.auth.signInWithOtp({
|
|
email: 'example@email.com',
|
|
})
|
|
```
|
|
- id: sign-in-with-sms-otp.
|
|
name: Sign in with SMS OTP.
|
|
isSpotlight: false
|
|
description: The user will be sent a SMS which contains a OTP. By default, a given user can only request a OTP once every 60 seconds.
|
|
js: |
|
|
```js
|
|
const { data, error } = await supabase.auth.signInWithOtp({
|
|
phone: '+13334445555',
|
|
})
|
|
```
|
|
- id: auth.signInWithOAuth()
|
|
title: 'signInWithOAuth()'
|
|
$ref: '@supabase/gotrue-js.GoTrueClient.signInWithOAuth'
|
|
notes: |
|
|
- This method is used for signing in using a third-party provider.
|
|
- Supabase supports many different [third-party providers](https://supabase.com/docs/guides/auth#providers).
|
|
examples:
|
|
- id: sign-in-using-a-third-party-provider
|
|
name: Sign in using a third-party provider
|
|
|
|
isSpotlight: true
|
|
js: |
|
|
```js
|
|
const { data, error } = await supabase.auth.signInWithOAuth({
|
|
provider: 'github'
|
|
})
|
|
```
|
|
- id: sign-in-using-a-third-party-provider-with-redirect
|
|
name: Sign in using a third-party provider with redirect
|
|
isSpotlight: false
|
|
description: |
|
|
When the third-party provider successfully authenticates the user, the provider will redirect the user to the URL specified in the `redirectTo` parameter. This parameter defaults to the [`SITE_URL`](https://supabase.com/docs/guides/auth/redirect-urls). It does not redirect the user immediately after invoking this method.
|
|
You can modify the `SITE_URL` or add additional redirect URLs in [your project](https://supabase.com/dashboard/project/_/auth/url-configuration).
|
|
js: |
|
|
```js
|
|
const { data, error } = await supabase.auth.signInWithOAuth({
|
|
provider: 'github',
|
|
options: {
|
|
redirectTo: 'https://example.com/welcome'
|
|
}
|
|
})
|
|
```
|
|
- id: sign-in-with-scopes
|
|
name: Sign in with scopes
|
|
isSpotlight: false
|
|
description: |
|
|
If you need additional data from an OAuth provider, you can include a space-separated list of scopes in your request to get back an OAuth provider token.
|
|
You may also need to specify the scopes in the provider's OAuth app settings, depending on the provider. The list of scopes will be documented by the third-party provider you are using and specifying scopes will enable you to use the OAuth provider token to call additional APIs supported by the third-party provider to get more information.
|
|
js: |
|
|
```js
|
|
const { data, error } = await supabase.auth.signInWithOAuth({
|
|
provider: 'github',
|
|
options: {
|
|
scopes: 'repo gist notifications'
|
|
}
|
|
})
|
|
const oAuthToken = data.session.provider_token // use to access provider API
|
|
```
|
|
- id: auth.signOut()
|
|
title: 'signOut()'
|
|
$ref: '@supabase/gotrue-js.GoTrueClient.signOut'
|
|
notes: |
|
|
- In order to use the `signOut()` method, the user needs to be signed in first.
|
|
examples:
|
|
- id: sign-out
|
|
name: Sign out
|
|
isSpotlight: true
|
|
js: |
|
|
```js
|
|
const { error } = await supabase.auth.signOut()
|
|
```
|
|
- id: auth.verifyOtp()
|
|
title: 'verifyOtp()'
|
|
$ref: '@supabase/gotrue-js.GoTrueClient.verifyOtp'
|
|
notes: |
|
|
- The `verifyOtp` method takes in different verification types. If a phone number is used, the type can either be `sms` or `phone_change`. If an email address is used, the type can be one of the following: `signup`, `magiclink`, `recovery`, `invite` or `email_change`.
|
|
- The verification type used should be determined based on the corresponding auth method called before `verifyOtp` to sign up / sign-in a user.
|
|
examples:
|
|
- id: verify-sms-one-time-password(otp)
|
|
name: Verify Sms One-Time Password (OTP)
|
|
isSpotlight: true
|
|
js: |
|
|
```js
|
|
const { data, error } = await supabase.auth.verifyOtp({ phone, token, type: 'sms'})
|
|
```
|
|
- id: verify-signup-one-time-password(otp)
|
|
name: Verify Signup One-Time Password (OTP)
|
|
isSpotlight: false
|
|
js: |
|
|
```js
|
|
const { data, error } = await supabase.auth.verifyOtp({ email, token, type: 'signup'})
|
|
```
|
|
- id: verify-email-auth(tokenhash)
|
|
name: Verify Email Auth (Token Hash)
|
|
isSpotlight: false
|
|
code: |
|
|
```js
|
|
const { data, error } = await supabase.auth.verifyOtp({ token_hash: tokenHash, type: 'email'})
|
|
```
|
|
- id: auth.getSession()
|
|
title: 'getSession()'
|
|
$ref: '@supabase/gotrue-js.GoTrueClient.getSession'
|
|
examples:
|
|
- id: get-the-session-data
|
|
name: Get the session data
|
|
isSpotlight: true
|
|
js: |
|
|
```js
|
|
const { data, error } = await supabase.auth.getSession()
|
|
```
|
|
- id: auth.getUser()
|
|
title: 'getUser()'
|
|
$ref: '@supabase/gotrue-js.GoTrueClient.getUser'
|
|
notes: |
|
|
- This method gets the user object from the current session.
|
|
- Fetches the user object from the database instead of local session.
|
|
examples:
|
|
- id: get-the-logged-in-user-with-the-current-existing-session
|
|
name: Get the logged in user with the current existing session
|
|
isSpotlight: true
|
|
js: |
|
|
```js
|
|
const { data: { user } } = await supabase.auth.getUser()
|
|
```
|
|
- id: get-the-logged-in-user-with-a-custom-access-token-jwt
|
|
name: Get the logged in user with a custom access token jwt.
|
|
isSpotlight: false
|
|
js: |
|
|
```js
|
|
const { data: { user } } = await supabase.auth.getUser(jwt)
|
|
```
|
|
- id: auth.updateUser()
|
|
title: 'updateUser()'
|
|
$ref: '@supabase/gotrue-js.GoTrueClient.updateUser'
|
|
notes: |
|
|
- In order to use the `updateUser()` method, the user needs to be signed in first.
|
|
- By Default, email updates sends a confirmation link to both the user's current and new email.
|
|
To only send a confirmation link to the user's new email, disable **Secure email change** in your project's [email auth provider settings](https://supabase.com/dashboard/project/_/auth/providers).
|
|
examples:
|
|
- id: update-the-email-for-an-authenticated-user
|
|
name: Update the email for an authenticated user
|
|
description: Sends a "Confirm Email Change" email to the new email address.
|
|
isSpotlight: false
|
|
js: |
|
|
```js
|
|
const { data, error } = await supabase.auth.updateUser({email: 'new@email.com'})
|
|
```
|
|
- id: update-the-password-for-an-authenticated-user
|
|
name: Update the password for an authenticated user
|
|
isSpotlight: false
|
|
js: |
|
|
```js
|
|
const { data, error } = await supabase.auth.updateUser({password: 'new password'})
|
|
```
|
|
- id: update-the-user's-metadata
|
|
name: Update the user's metadata
|
|
isSpotlight: true
|
|
js: |
|
|
```js
|
|
const { data, error } = await supabase.auth.updateUser({
|
|
data: { hello: 'world' }
|
|
})
|
|
```
|
|
- id: auth.setSession()
|
|
title: 'setSession()'
|
|
$ref: '@supabase/gotrue-js.GoTrueClient.setSession'
|
|
notes: |
|
|
- `setSession()` takes in a refresh token and uses it to get a new session.
|
|
- The refresh token can only be used once to obtain a new session.
|
|
- [Refresh token rotation](/docs/reference/auth/config#refresh_token_rotation_enabled) is enabled by default on all projects to guard against replay attacks.
|
|
- You can configure the [`REFRESH_TOKEN_REUSE_INTERVAL`](https://supabase.com/docs/reference/auth/config#refresh_token_reuse_interval) which provides a short window in which the same refresh token can be used multiple times in the event of concurrency or offline issues.
|
|
examples:
|
|
- id: refresh-the-session
|
|
name: Refresh the session
|
|
description: Sets the session data from refresh_token and returns current session or an error if the refresh_token is invalid.
|
|
isSpotlight: true
|
|
js: |
|
|
```js
|
|
const { data, error } = supabase.auth.setSession(refresh_token)
|
|
```
|
|
- id: auth.refreshSession()
|
|
title: 'refreshSession()'
|
|
$ref: '@supabase/gotrue-js.GoTrueClient.refreshSession'
|
|
notes: |
|
|
- This method will refresh the session whether the current one is expired or not.
|
|
- Both examples destructure `user` and `session` from `data`. This is not required; so `const { data, error } =` is also valid.
|
|
examples:
|
|
- id: refresh-session-using-the-current-session
|
|
name: Refresh session using the current session
|
|
isSpotlight: true
|
|
js: |
|
|
```js
|
|
const { data: { user, session }, error } = await supabase.auth.refreshSession()
|
|
```
|
|
- id: refresh-session-using-a-passed-in-session
|
|
name: Refresh session using a passed-in session
|
|
isSpotlight: true
|
|
js: |
|
|
```js
|
|
const { data: { user, session }, error } = await supabase.auth.refreshSession({ refresh_token })
|
|
```
|
|
- id: auth.onAuthStateChange()
|
|
title: 'onAuthStateChange()'
|
|
$ref: '@supabase/gotrue-js.GoTrueClient.onAuthStateChange'
|
|
notes: |
|
|
- Types of auth events: `SIGNED_IN`, `SIGNED_OUT`, `TOKEN_REFRESHED`, `USER_UPDATED`, `USER_DELETED`, `PASSWORD_RECOVERY`
|
|
examples:
|
|
- id: listen-to-auth-changes
|
|
name: Listen to auth changes
|
|
isSpotlight: true
|
|
js: |
|
|
```js
|
|
supabase.auth.onAuthStateChange((event, session) => {
|
|
console.log(event, session)
|
|
})
|
|
```
|
|
- id: listen-to-sign-in
|
|
name: Listen to sign in
|
|
js: |
|
|
```js
|
|
supabase.auth.onAuthStateChange((event, session) => {
|
|
if (event == 'SIGNED_IN') console.log('SIGNED_IN', session)
|
|
})
|
|
```
|
|
- id: listen-to-sign-out
|
|
name: Listen to sign out
|
|
js: |
|
|
```js
|
|
supabase.auth.onAuthStateChange((event, session) => {
|
|
if (event == 'SIGNED_OUT') console.log('SIGNED_OUT', session)
|
|
})
|
|
```
|
|
- id: listen-to-token-refresh
|
|
name: Listen to token refresh
|
|
js: |
|
|
```js
|
|
supabase.auth.onAuthStateChange((event, session) => {
|
|
if (event == 'TOKEN_REFRESHED') console.log('TOKEN_REFRESHED', session)
|
|
})
|
|
```
|
|
- id: listen-to-user-updates
|
|
name: Listen to user updates
|
|
js: |
|
|
```js
|
|
supabase.auth.onAuthStateChange((event, session) => {
|
|
if (event == 'USER_UPDATED') console.log('USER_UPDATED', session)
|
|
})
|
|
```
|
|
- id: listen-to-user-deleted
|
|
name: Listen to user deleted
|
|
js: |
|
|
```js
|
|
supabase.auth.onAuthStateChange((event, session) => {
|
|
if (event == 'USER_DELETED') console.log('USER_DELETED', session)
|
|
})
|
|
```
|
|
- id: listen-to-password-recovery-events
|
|
name: Listen to password recovery events
|
|
js: |
|
|
```js
|
|
supabase.auth.onAuthStateChange((event, session) => {
|
|
if (event == 'PASSWORD_RECOVERY') console.log('PASSWORD_RECOVERY', session)
|
|
})
|
|
```
|
|
- id: Supabase Auth Admin Api
|
|
title: 'Overview'
|
|
notes: |
|
|
- Any method under the `supabase.auth.admin` namespace requires a `service_role` key.
|
|
- These methods are considered admin methods and should be called on a trusted server. Never expose your `service_role` key in the browser.
|
|
|
|
- id: auth.admin.getUserById()
|
|
title: 'getUserById()'
|
|
$ref: '@supabase/gotrue-js.GoTrueAdminApi.getUserById'
|
|
notes: |
|
|
- Fetches the user object from the database based on the user's id.
|
|
- The `getUserById()` method requires the user's id which maps to the `auth.users.id` column.
|
|
examples:
|
|
- id: fetch-the-user-object-using-the-access-token-jwt
|
|
name: Fetch the user object using the access_token jwt.
|
|
isSpotlight: true
|
|
js: |
|
|
```js
|
|
const { data, error } = await supabase.auth.admin.getUserById(1)
|
|
```
|
|
|
|
- id: auth.admin.listUsers()
|
|
title: 'listUsers()'
|
|
$ref: '@supabase/gotrue-js.GoTrueAdminApi.listUsers'
|
|
examples:
|
|
- id: get-a-full-list-of-users.
|
|
name: Get a full list of users.
|
|
isSpotlight: true
|
|
js: |
|
|
```js
|
|
const { data: { users }, error } = await supabase.auth.admin.listUsers()
|
|
```
|
|
- id: auth.admin.createUser()
|
|
title: 'createUser()'
|
|
$ref: '@supabase/gotrue-js.GoTrueAdminApi.createUser'
|
|
notes: |
|
|
- To confirm the user's email address or phone number, set `email_confirm` or `phone_confirm` to true. Both arguments default to false.
|
|
examples:
|
|
- id: create-a-new-user-with-custom-user-metadata
|
|
name: Create a new user with custom user metadata
|
|
isSpotlight: true
|
|
js: |
|
|
```js
|
|
const { data, error } = await supabase.auth.admin.createUser({
|
|
email: 'user@email.com',
|
|
password: 'password',
|
|
user_metadata: { name: 'Yoda' }
|
|
})
|
|
```
|
|
- id: auto-confirm-the-user's-email
|
|
name: Auto-confirm the user's email
|
|
js: |
|
|
```js
|
|
const { data, error } = await supabase.auth.admin.createUser({
|
|
email: 'user@email.com',
|
|
email_confirm: true
|
|
})
|
|
```
|
|
- id: auto-confirm-the-user's-phone-number
|
|
name: Auto-confirm the user's phone number
|
|
js: |
|
|
```js
|
|
const { data, error } = await supabase.auth.admin.createUser({
|
|
phone: '1234567890',
|
|
phone_confirm: true
|
|
})
|
|
```
|
|
- id: auth.admin.deleteUser()
|
|
title: 'deleteUser()'
|
|
$ref: '@supabase/gotrue-js.GoTrueAdminApi.deleteUser'
|
|
notes: |
|
|
- The `deleteUser()` method requires the user's ID, which maps to the `auth.users.id` column.
|
|
examples:
|
|
- id: removes-a-user
|
|
name: Removes a user
|
|
isSpotlight: true
|
|
js: |
|
|
```js
|
|
const { data, error } = await supabase.auth.admin.deleteUser(
|
|
'715ed5db-f090-4b8c-a067-640ecee36aa0'
|
|
)
|
|
```
|
|
|
|
- id: auth.admin.inviteUserByEmail()
|
|
title: 'inviteUserByEmail()'
|
|
$ref: '@supabase/gotrue-js.GoTrueAdminApi.inviteUserByEmail'
|
|
notes: |
|
|
- Sends an invite link to the user's email address.
|
|
examples:
|
|
- id: invite-a-user
|
|
name: Invite a user
|
|
isSpotlight: true
|
|
js: |
|
|
```js
|
|
const { data, error } = await supabase.auth.admin.inviteUserByEmail('email@example.com')
|
|
```
|
|
|
|
- id: auth.resetPasswordForEmail()
|
|
title: 'resetPasswordForEmail()'
|
|
$ref: '@supabase/gotrue-js.GoTrueClient.resetPasswordForEmail'
|
|
notes: |
|
|
Sends a password reset request to an email address.
|
|
When the user clicks the reset link in the email they are redirected back to your application.
|
|
Prompt the user for a new password and call `auth.updateUser()`:
|
|
```js
|
|
const { data, error } = await supabase.auth
|
|
.updateUser({ password: new_password })
|
|
```
|
|
examples:
|
|
- id: reset-password
|
|
name: Reset password
|
|
isSpotlight: true
|
|
js: |
|
|
```js
|
|
const { data, error } = await supabase.auth.resetPasswordForEmail(email, {
|
|
redirectTo: 'https://example.com/update-password',
|
|
})
|
|
```
|
|
- id: reset-password(react)
|
|
name: Reset password (React)
|
|
isSpotlight: true
|
|
js: |
|
|
```js
|
|
/**
|
|
* Step 1: Send the user an email to get a password reset token.
|
|
* This email contains a link which sends the user back to your application.
|
|
*/
|
|
const { data, error } = await supabase.auth
|
|
.resetPasswordForEmail('user@email.com')
|
|
|
|
/**
|
|
* Step 2: Once the user is redirected back to your application,
|
|
* ask the user to reset their password.
|
|
*/
|
|
useEffect(() => {
|
|
supabase.auth.onAuthStateChange(async (event, session) => {
|
|
if (event == "PASSWORD_RECOVERY") {
|
|
const newPassword = prompt("What would you like your new password to be?");
|
|
const { data, error } = await supabase.auth
|
|
.updateUser({ password: newPassword })
|
|
|
|
if (data) alert("Password updated successfully!")
|
|
if (error) alert("There was an error updating your password.")
|
|
}
|
|
})
|
|
}, [])
|
|
```
|
|
|
|
- id: auth.admin.generateLink()
|
|
title: 'generateLink()'
|
|
$ref: '@supabase/gotrue-js.GoTrueAdminApi.generateLink'
|
|
examples:
|
|
- id: generate-a-signup-link
|
|
name: Generate a signup link
|
|
isSpotlight: true
|
|
js: |
|
|
```js
|
|
const { data, error } = await supabase.auth.admin.generateLink({
|
|
type: 'signup',
|
|
email: 'email@example.com',
|
|
options: {
|
|
'password': 'secret'
|
|
}
|
|
})
|
|
```
|
|
- id: generate-an-invite-link
|
|
name: Generate an invite link
|
|
isSpotlight: false
|
|
js: |
|
|
```js
|
|
const { data, error } = await supabase.auth.admin.generateLink({
|
|
type: 'invite',
|
|
email: 'email@example.com'
|
|
})
|
|
```
|
|
- id: generate-a-magic-link
|
|
name: Generate a magic link
|
|
isSpotlight: false
|
|
js: |
|
|
```js
|
|
const { data, error } = await supabase.auth.admin.generateLink({
|
|
type: 'magiclink',
|
|
email: 'email@example.com'
|
|
})
|
|
```
|
|
- id: generate-a-recovery-link
|
|
name: Generate a recovery link
|
|
isSpotlight: false
|
|
js: |
|
|
```js
|
|
const { data, error } = await supabase.auth.admin.generateLink({
|
|
type: 'recovery',
|
|
email: 'email@example.com'
|
|
})
|
|
```
|
|
- id: generate-links-to-change-current-email-address
|
|
name: Generate links to change current email address
|
|
isSpotlight: false
|
|
js: |
|
|
```js
|
|
// generate an email change link to be sent to the current email address
|
|
const { data, error } = await supabase.auth.admin.generateLink({
|
|
type: 'email_change_current',
|
|
email: 'current.email@example.com',
|
|
newEmail: 'new.email@example.com'
|
|
})
|
|
|
|
// generate an email change link to be sent to the new email address
|
|
const { data, error } = await supabase.auth.admin.generateLink({
|
|
type: 'email_change_new',
|
|
email: 'current.email@example.com',
|
|
newEmail: 'new.email@example.com'
|
|
})
|
|
```
|
|
|
|
- id: auth.admin.updateUserById()
|
|
title: 'updateUserById()'
|
|
$ref: '@supabase/gotrue-js.GoTrueAdminApi.updateUserById'
|
|
examples:
|
|
- id: updates-a-users-email.
|
|
name: Updates a user's email.
|
|
isSpotlight: false
|
|
js: |
|
|
```js
|
|
const { data: user, error } = await supabase.auth.admin.updateUserById(
|
|
'6aa5d0d4-2a9f-4483-b6c8-0cf4c6c98ac4',
|
|
{ email: 'new@email.com' }
|
|
)
|
|
```
|
|
- id: updates-a-users-password.
|
|
name: Updates a user's password.
|
|
isSpotlight: false
|
|
js: |
|
|
```js
|
|
const { data: user, error } = await supabase.auth.admin.updateUserById(
|
|
'6aa5d0d4-2a9f-4483-b6c8-0cf4c6c98ac4',
|
|
{ password: 'new_password' }
|
|
)
|
|
```
|
|
- id: updates-a-users-metadata.
|
|
name: Updates a user's metadata.
|
|
isSpotlight: true
|
|
js: |
|
|
```js
|
|
const { data: user, error } = await supabase.auth.admin.updateUserById(
|
|
'6aa5d0d4-2a9f-4483-b6c8-0cf4c6c98ac4',
|
|
{ user_metadata: { hello: 'world' } }
|
|
)
|
|
```
|
|
- id: updates-a-users-app-metadata.
|
|
name: Updates a user's app_metadata.
|
|
isSpotlight: false
|
|
js: |
|
|
```js
|
|
const { data: user, error } = await supabase.auth.admin.updateUserById(
|
|
'6aa5d0d4-2a9f-4483-b6c8-0cf4c6c98ac4',
|
|
{ app_metadata: { plan: 'trial' } }
|
|
)
|
|
```
|
|
- id: confirms-a-users-email-address.
|
|
name: Confirms a user's email address.
|
|
isSpotlight: false
|
|
js: |
|
|
```js
|
|
const { data: user, error } = await supabase.auth.admin.updateUserById(
|
|
'6aa5d0d4-2a9f-4483-b6c8-0cf4c6c98ac4',
|
|
{ email_confirm: true }
|
|
)
|
|
```
|
|
- id: confirms-a-users-phone-number.
|
|
name: Confirms a user's phone number.
|
|
isSpotlight: false
|
|
js: |
|
|
```js
|
|
const { data: user, error } = await supabase.auth.admin.updateUserById(
|
|
'6aa5d0d4-2a9f-4483-b6c8-0cf4c6c98ac4',
|
|
{ phone_confirm: true }
|
|
)
|
|
```
|
|
|
|
- id: select()
|
|
title: 'Fetching data'
|
|
description: 'This is the description'
|
|
$ref: '@supabase/postgrest-js.PostgrestQueryBuilder.select'
|
|
notes: |
|
|
- By default, Supabase projects return a maximum of 1,000 rows. This setting can be changed in your project's [API settings](https://supabase.com/dashboard/project/_/settings/api). It's recommended that you keep it low to limit the payload size of accidental or malicious requests. You can use `range()` queries to paginate through your data.
|
|
- `select()` can be combined with [Filters](/docs/reference/javascript/using-filters)
|
|
- `select()` can be combined with [Modifiers](/docs/reference/javascript/using-modifiers)
|
|
- `apikey` is a reserved keyword if you're using the [Supabase Platform](/docs/guides/platform) and [should be avoided as a column name](https://github.com/supabase/supabase/issues/5465).
|
|
examples:
|
|
- id: getting-your-data
|
|
name: Getting your data
|
|
data:
|
|
sql: |
|
|
create table
|
|
countries (id int8 primary key, name text);
|
|
|
|
insert into
|
|
countries (id, name)
|
|
values
|
|
(1, 'Afghanistan'),
|
|
(2, 'Albania'),
|
|
(3, 'Algeria');
|
|
tables:
|
|
- schema: public
|
|
name: countries
|
|
content: |
|
|
| name | id |
|
|
| :-----------------------|------:|
|
|
| Afghanistan | 1 |
|
|
| Albania | 2 |
|
|
| Algeria | 3 |
|
|
response: |
|
|
{
|
|
"data": [
|
|
{
|
|
"id": 1,
|
|
"name": "Afghanistan"
|
|
},
|
|
{
|
|
"id": 2,
|
|
"name": "Albania"
|
|
},
|
|
{
|
|
"id": 3,
|
|
"name": "Algeria"
|
|
}
|
|
],
|
|
"status": 200,
|
|
"statusText": "OK"
|
|
}
|
|
- id: selecting-specific-columns
|
|
name: Selecting specific columns
|
|
description: |
|
|
You can select specific fields from your tables.
|
|
data:
|
|
sql: |
|
|
create table
|
|
countries (id int8 primary key, name text);
|
|
|
|
insert into
|
|
countries (id, name)
|
|
values
|
|
(1, 'Afghanistan'),
|
|
(2, 'Albania'),
|
|
(3, 'Algeria');
|
|
tables:
|
|
- schema: public
|
|
name: countries
|
|
content: |
|
|
| name | id |
|
|
| :-----------------------|------:|
|
|
| Afghanistan | 1 |
|
|
| Albania | 2 |
|
|
| Algeria | 3 |
|
|
response: |
|
|
{
|
|
"data": [
|
|
{
|
|
"name": "Afghanistan"
|
|
},
|
|
{
|
|
"name": "Albania"
|
|
},
|
|
{
|
|
"name": "Algeria"
|
|
}
|
|
],
|
|
"status": 200,
|
|
"statusText": "OK"
|
|
}
|
|
hideCodeBlock: true
|
|
- id: query-foreign-tables
|
|
name: Query referenced tables
|
|
description: |
|
|
If your database has foreign key relationships, you can query related tables too.
|
|
code: |
|
|
```ts
|
|
const { data, error } = await supabase
|
|
.from('countries')
|
|
.select(`
|
|
name,
|
|
cities (
|
|
name
|
|
)
|
|
`)
|
|
```
|
|
data:
|
|
sql: |
|
|
create table
|
|
countries (id int8 primary key, name text);
|
|
create table
|
|
cities (
|
|
id int8 primary key,
|
|
country_id int8 not null references countries,
|
|
name text
|
|
);
|
|
|
|
insert into
|
|
countries (id, name)
|
|
values
|
|
(1, 'Germany'),
|
|
(2, 'Indonesia');
|
|
insert into
|
|
cities (id, country_id, name)
|
|
values
|
|
(1, 2, 'Bali'),
|
|
(2, 1, 'Munich');
|
|
tables:
|
|
- schema: public
|
|
name: countries
|
|
content: |
|
|
| name | id |
|
|
| :-----------------------|------:|
|
|
| Germany | 1 |
|
|
| Indonesia | 2 |
|
|
- schema: public
|
|
name: cities
|
|
content: |
|
|
| name | id |
|
|
| :-----------------------|------:|
|
|
| Bali | 1 |
|
|
| Munich | 2 |
|
|
response: |
|
|
{
|
|
"data": [
|
|
{
|
|
"name": "Germany",
|
|
"cities": [
|
|
{
|
|
"name": "Munich"
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"name": "Indonesia",
|
|
"cities": [
|
|
{
|
|
"name": "Bali"
|
|
}
|
|
]
|
|
}
|
|
],
|
|
"status": 200,
|
|
"statusText": "OK"
|
|
}
|
|
|
|
- id: query-foreign-tables-through-a-join-table
|
|
name: Query referenced tables through a join table
|
|
data:
|
|
sql: |
|
|
create table
|
|
users (
|
|
id int8 primary key,
|
|
name text
|
|
);
|
|
create table
|
|
teams (
|
|
id int8 primary key,
|
|
name text
|
|
);
|
|
-- join table
|
|
create table
|
|
users_teams (
|
|
user_id int8 not null references users,
|
|
team_id int8 not null references teams,
|
|
-- both foreign keys must be part of a composite primary key
|
|
primary key (user_id, team_id)
|
|
);
|
|
|
|
insert into
|
|
users (id, name)
|
|
values
|
|
(1, 'Kiran'),
|
|
(2, 'Evan');
|
|
insert into
|
|
teams (id, name)
|
|
values
|
|
(1, 'Green'),
|
|
(2, 'Blue');
|
|
insert into
|
|
users_teams (user_id, team_id)
|
|
values
|
|
(1, 1),
|
|
(1, 2),
|
|
(2, 2);
|
|
response: |
|
|
{
|
|
"data": [
|
|
{
|
|
"name": "Kiran",
|
|
"teams": [
|
|
{
|
|
"name": "Green"
|
|
},
|
|
{
|
|
"name": "Blue"
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"name": "Evan",
|
|
"teams": [
|
|
{
|
|
"name": "Blue"
|
|
}
|
|
]
|
|
}
|
|
],
|
|
"status": 200,
|
|
"statusText": "OK"
|
|
}
|
|
description: |
|
|
If you're in a situation where your tables are **NOT** directly
|
|
related, but instead are joined by a _join table_, you can still use
|
|
the `select()` method to query the related data. The join table needs
|
|
to have the foreign keys as part of its composite primary key.
|
|
code: |
|
|
```ts
|
|
const { data, error } = await supabase
|
|
.from('users')
|
|
.select(`
|
|
name,
|
|
teams (
|
|
name
|
|
)
|
|
`)
|
|
```
|
|
- id: query-the-same-foreign-table-multiple-times
|
|
name: Query the same referenced table multiple times
|
|
description: |
|
|
If you need to query the same referenced table twice, use the name of the
|
|
joined column to identify which join to use. You can also give each
|
|
column an alias.
|
|
|
|
<Tabs scrollable size="small" type="underlined" defaultActiveId="schema">
|
|
<TabPanel id="schema" label="Schema">
|
|
|
|
```sql
|
|
create table
|
|
users (id int8 primary key, name text);
|
|
|
|
create table
|
|
messages (
|
|
sender_id int8 not null references users,
|
|
receiver_id int8 not null references users,
|
|
content text
|
|
);
|
|
|
|
insert into
|
|
users (id, name)
|
|
values
|
|
(1, 'Kiran'),
|
|
(2, 'Evan');
|
|
|
|
insert into
|
|
messages (sender_id, receiver_id, content)
|
|
values
|
|
(1, 2, '👋');
|
|
```
|
|
|
|
</TabPanel>
|
|
<TabPanel id="js" label="JavaScript">
|
|
|
|
```ts
|
|
const { data, error } = await supabase
|
|
.from('messages')
|
|
.select(`
|
|
content,
|
|
from:sender_id(name),
|
|
to:receiver_id(name)
|
|
`)
|
|
```
|
|
|
|
</TabPanel>
|
|
<TabPanel id="result" label="Result">
|
|
|
|
```json
|
|
{
|
|
"data": [
|
|
{
|
|
"content": "👋",
|
|
"from": {
|
|
"name": "Kiran"
|
|
},
|
|
"to": {
|
|
"name": "Evan"
|
|
}
|
|
}
|
|
],
|
|
"status": 200,
|
|
"statusText": "OK"
|
|
}
|
|
```
|
|
|
|
</TabPanel>
|
|
</Tabs>
|
|
hideCodeBlock: true
|
|
- id: query-nested-foreign-tables-through-a-join-table
|
|
name: Query nested foreign tables through a join table
|
|
code: |
|
|
```ts
|
|
const { data, error } = await supabase
|
|
.from('games')
|
|
.select(`
|
|
game_id:id,
|
|
away_team:teams!games_away_team_fkey (
|
|
users (
|
|
id,
|
|
name
|
|
)
|
|
)
|
|
`)
|
|
```
|
|
data:
|
|
sql: |
|
|
```sql
|
|
create table
|
|
users (
|
|
id int8 primary key,
|
|
name text
|
|
);
|
|
create table
|
|
teams (
|
|
id int8 primary key,
|
|
name text
|
|
);
|
|
-- join table
|
|
create table
|
|
users_teams (
|
|
user_id int8 not null references users,
|
|
team_id int8 not null references teams,
|
|
|
|
primary key (user_id, team_id)
|
|
);
|
|
create table
|
|
games (
|
|
id int8 primary key,
|
|
home_team int8 not null references teams,
|
|
away_team int8 not null references teams,
|
|
name text
|
|
);
|
|
|
|
insert into users (id, name)
|
|
values
|
|
(1, 'Kiran'),
|
|
(2, 'Evan');
|
|
insert into
|
|
teams (id, name)
|
|
values
|
|
(1, 'Green'),
|
|
(2, 'Blue');
|
|
insert into
|
|
users_teams (user_id, team_id)
|
|
values
|
|
(1, 1),
|
|
(1, 2),
|
|
(2, 2);
|
|
insert into
|
|
games (id, home_team, away_team, name)
|
|
values
|
|
(1, 1, 2, 'Green vs Blue'),
|
|
(2, 2, 1, 'Blue vs Green');
|
|
```
|
|
response: |
|
|
```json
|
|
{
|
|
"data": [
|
|
{
|
|
"game_id": 1,
|
|
"away_team": {
|
|
"users": [
|
|
{
|
|
"id": 1,
|
|
"name": "Kiran"
|
|
},
|
|
{
|
|
"id": 2,
|
|
"name": "Evan"
|
|
}
|
|
]
|
|
}
|
|
},
|
|
{
|
|
"game_id": 2,
|
|
"away_team": {
|
|
"users": [
|
|
{
|
|
"id": 1,
|
|
"name": "Kiran"
|
|
}
|
|
]
|
|
}
|
|
}
|
|
],
|
|
"status": 200,
|
|
"statusText": "OK"
|
|
}
|
|
```
|
|
description: |
|
|
You can use the result of a joined table to gather data in
|
|
another foreign table. With multiple references to the same foreign
|
|
table you must specify the column on which to conduct the join.
|
|
hideCodeBlock: true
|
|
- id: filtering-through-foreign-tables
|
|
name: Filtering through referenced tables
|
|
description: |
|
|
If the filter on a referenced table's column is not satisfied, the referenced
|
|
table returns `[]` or `null` but the parent table is not filtered out.
|
|
|
|
<Tabs scrollable size="small" type="underlined" defaultActiveId="schema">
|
|
<TabPanel id="schema" label="Schema">
|
|
|
|
```sql
|
|
create table
|
|
countries (id int8 primary key, name text);
|
|
create table
|
|
cities (
|
|
id int8 primary key,
|
|
country_id int8 not null references countries,
|
|
name text
|
|
);
|
|
|
|
insert into
|
|
countries (id, name)
|
|
values
|
|
(1, 'Germany'),
|
|
(2, 'Indonesia');
|
|
insert into
|
|
cities (id, country_id, name)
|
|
values
|
|
(1, 2, 'Bali'),
|
|
(2, 1, 'Munich');
|
|
```
|
|
|
|
</TabPanel>
|
|
<TabPanel id="js" label="JavaScript">
|
|
|
|
```ts
|
|
const { data, error } = await supabase
|
|
.from('cities')
|
|
.select('name, countries(*)')
|
|
.eq('countries.name', 'Estonia')
|
|
```
|
|
|
|
</TabPanel>
|
|
<TabPanel id="result" label="Result">
|
|
|
|
```json
|
|
{
|
|
"data": [
|
|
{
|
|
"name": "Bali",
|
|
"countries": null
|
|
},
|
|
{
|
|
"name": "Munich",
|
|
"countries": null
|
|
}
|
|
],
|
|
"status": 200,
|
|
"statusText": "OK"
|
|
}
|
|
```
|
|
|
|
</TabPanel>
|
|
</Tabs>
|
|
|
|
If you want to filter out the parent table rows, use the `!inner` hint:
|
|
|
|
<Tabs scrollable size="small" type="underlined" defaultActiveId="js">
|
|
<TabPanel id="js" label="JavaScript">
|
|
|
|
```ts
|
|
const { data, error } = await supabase
|
|
.from('cities')
|
|
.select('name, countries!inner(*)')
|
|
.eq('countries.name', 'Estonia')
|
|
```
|
|
|
|
</TabPanel>
|
|
<TabPanel id="result" label="Result">
|
|
|
|
```json
|
|
{
|
|
"data": [],
|
|
"status": 200,
|
|
"statusText": "OK"
|
|
}
|
|
```
|
|
|
|
</TabPanel>
|
|
</Tabs>
|
|
hideCodeBlock: true
|
|
- id: querying-with-count-option
|
|
name: Querying with count option
|
|
description: |
|
|
You can get the number of rows by using the
|
|
[count](/docs/reference/javascript/select#parameters) option. For
|
|
example, to get the table count without returning all rows:
|
|
|
|
<Tabs scrollable size="small" type="underlined" defaultActiveId="schema">
|
|
<TabPanel id="schema" label="Schema">
|
|
|
|
```sql
|
|
create table
|
|
countries (id int8 primary key, name text);
|
|
|
|
insert into
|
|
countries (id, name)
|
|
values
|
|
(1, 'Afghanistan'),
|
|
(2, 'Albania'),
|
|
(3, 'Algeria');
|
|
```
|
|
|
|
</TabPanel>
|
|
<TabPanel id="js" label="JavaScript">
|
|
|
|
```ts
|
|
const { count, error } = await supabase
|
|
.from('countries')
|
|
.select('*', { count: 'exact', head: true })
|
|
```
|
|
|
|
</TabPanel>
|
|
<TabPanel id="result" label="Result">
|
|
|
|
```json
|
|
{
|
|
"count": 3,
|
|
"status": 200,
|
|
"statusText": "OK"
|
|
}
|
|
```
|
|
|
|
</TabPanel>
|
|
</Tabs>
|
|
hideCodeBlock: true
|
|
- id: querying-json-data
|
|
name: Querying JSON data
|
|
description: |
|
|
You can select and filter data inside of
|
|
[JSON](/docs/guides/database/json) columns. Postgres offers some
|
|
[operators](/docs/guides/database/json#query-the-jsonb-data) for
|
|
querying JSON data.
|
|
|
|
<Tabs scrollable size="small" type="underlined" defaultActiveId="schema">
|
|
<TabPanel id="schema" label="Schema">
|
|
|
|
```sql
|
|
create table
|
|
users (
|
|
id int8 primary key,
|
|
name text,
|
|
address jsonb
|
|
);
|
|
|
|
insert into
|
|
users (id, name, address)
|
|
values
|
|
(1, 'Avdotya', '{"city":"Saint Petersburg"}');
|
|
```
|
|
|
|
</TabPanel>
|
|
<TabPanel id="js" label="JavaScript">
|
|
|
|
```ts
|
|
const { data, error } = await supabase
|
|
.from('users')
|
|
.select(`
|
|
id, name,
|
|
address->city
|
|
`)
|
|
```
|
|
|
|
</TabPanel>
|
|
<TabPanel id="result" label="Result">
|
|
|
|
```json
|
|
{
|
|
"data": [
|
|
{
|
|
"id": 1,
|
|
"name": "Avdotya",
|
|
"city": "Saint Petersburg"
|
|
}
|
|
],
|
|
"status": 200,
|
|
"statusText": "OK"
|
|
}
|
|
```
|
|
|
|
</TabPanel>
|
|
</Tabs>
|
|
hideCodeBlock: true
|
|
|
|
- id: insert()
|
|
title: 'Create data: insert()'
|
|
$ref: '@supabase/postgrest-js.PostgrestQueryBuilder.insert'
|
|
examples:
|
|
- id: create-a-record
|
|
name: Create a record
|
|
description: |
|
|
<Tabs scrollable size="small" type="underlined" defaultActiveId="schema">
|
|
<TabPanel id="schema" label="Schema">
|
|
|
|
```sql
|
|
create table
|
|
countries (id int8 primary key, name text);
|
|
```
|
|
|
|
</TabPanel>
|
|
<TabPanel id="js" label="JavaScript">
|
|
|
|
```ts
|
|
const { error } = await supabase
|
|
.from('countries')
|
|
.insert({ id: 1, name: 'Denmark' })
|
|
```
|
|
|
|
</TabPanel>
|
|
<TabPanel id="result" label="Result">
|
|
|
|
```json
|
|
{
|
|
"status": 201,
|
|
"statusText": "Created"
|
|
}
|
|
```
|
|
</TabPanel>
|
|
</Tabs>
|
|
|
|
<Tabs scrollable size="small" type="underlined" defaultActiveId="js">
|
|
<TabPanel id="js" label="JavaScript">
|
|
|
|
```ts
|
|
const { data, error } = await supabase
|
|
.from('countries')
|
|
.select()
|
|
```
|
|
|
|
</TabPanel>
|
|
<TabPanel id="result" label="Result">
|
|
|
|
```json
|
|
{
|
|
"data": [
|
|
{
|
|
"id": 1,
|
|
"name": "Denmark"
|
|
}
|
|
],
|
|
"status": 200,
|
|
"statusText": "OK"
|
|
}
|
|
```
|
|
|
|
</TabPanel>
|
|
</Tabs>
|
|
hideCodeBlock: true
|
|
isSpotlight: true
|
|
js: |
|
|
```ts
|
|
const { error } = await supabase
|
|
.from('countries')
|
|
.insert({ id: 1, name: 'Denmark' })
|
|
```
|
|
- id: create-a-record-and-return-it
|
|
name: Create a record and return it
|
|
description: |
|
|
<Tabs scrollable size="small" type="underlined" defaultActiveId="schema">
|
|
<TabPanel id="schema" label="Schema">
|
|
|
|
```sql
|
|
create table
|
|
countries (id int8 primary key, name text);
|
|
```
|
|
|
|
</TabPanel>
|
|
<TabPanel id="js" label="JavaScript">
|
|
|
|
```ts
|
|
const { data, error } = await supabase
|
|
.from('countries')
|
|
.insert({ id: 1, name: 'Denmark' })
|
|
.select()
|
|
```
|
|
|
|
</TabPanel>
|
|
<TabPanel id="result" label="Result">
|
|
|
|
```json
|
|
{
|
|
"data": [
|
|
{
|
|
"id": 1,
|
|
"name": "Denmark"
|
|
}
|
|
],
|
|
"status": 201,
|
|
"statusText": "Created"
|
|
}
|
|
```
|
|
|
|
</TabPanel>
|
|
</Tabs>
|
|
hideCodeBlock: true
|
|
- id: bulk-create
|
|
name: Bulk create
|
|
description: |
|
|
A bulk create operation is handled in a single transaction.
|
|
If any of the inserts fail, none of the rows are inserted.
|
|
|
|
<Tabs scrollable size="small" type="underlined" defaultActiveId="schema">
|
|
<TabPanel id="schema" label="Schema">
|
|
|
|
```sql
|
|
create table
|
|
countries (id int8 primary key, name text);
|
|
```
|
|
|
|
</TabPanel>
|
|
<TabPanel id="js" label="JavaScript">
|
|
|
|
```ts
|
|
const { error } = await supabase
|
|
.from('countries')
|
|
.insert([
|
|
{ id: 1, name: 'Nepal' },
|
|
{ id: 1, name: 'Vietnam' },
|
|
])
|
|
```
|
|
|
|
</TabPanel>
|
|
<TabPanel id="result" label="Result">
|
|
|
|
```json
|
|
{
|
|
"error": {
|
|
"code": "23505",
|
|
"details": "Key (id)=(1) already exists.",
|
|
"hint": null,
|
|
"message": "duplicate key value violates unique constraint \"countries_pkey\""
|
|
},
|
|
"status": 409,
|
|
"statusText": "Conflict"
|
|
}
|
|
```
|
|
|
|
</TabPanel>
|
|
</Tabs>
|
|
|
|
<Tabs scrollable size="small" type="underlined" defaultActiveId="js">
|
|
<TabPanel id="js" label="JavaScript">
|
|
|
|
```ts
|
|
const { data, error } = await supabase
|
|
.from('countries')
|
|
.select()
|
|
```
|
|
|
|
</TabPanel>
|
|
<TabPanel id="result" label="Result">
|
|
|
|
```json
|
|
{
|
|
"data": [],
|
|
"status": 200,
|
|
"statusText": "OK"
|
|
}
|
|
```
|
|
|
|
</TabPanel>
|
|
</Tabs>
|
|
hideCodeBlock: true
|
|
|
|
- id: update()
|
|
title: 'Modify data: update()'
|
|
$ref: '@supabase/postgrest-js.PostgrestQueryBuilder.update'
|
|
notes: |
|
|
- `update()` should always be combined with [Filters](/docs/reference/javascript/using-filters) to target the item(s) you wish to update.
|
|
examples:
|
|
- id: updating-your-data
|
|
name: Updating your data
|
|
description: |
|
|
<Tabs scrollable size="small" type="underlined" defaultActiveId="schema">
|
|
<TabPanel id="schema" label="Schema">
|
|
|
|
```sql
|
|
create table
|
|
countries (id int8 primary key, name text);
|
|
|
|
insert into
|
|
countries (id, name)
|
|
values
|
|
(1, 'Taiwan');
|
|
```
|
|
|
|
</TabPanel>
|
|
<TabPanel id="js" label="JavaScript">
|
|
|
|
```ts
|
|
const { error } = await supabase
|
|
.from('countries')
|
|
.update({ name: 'Australia' })
|
|
.eq('id', 1)
|
|
```
|
|
|
|
</TabPanel>
|
|
<TabPanel id="result" label="Result">
|
|
|
|
```json
|
|
{
|
|
"status": 204,
|
|
"statusText": "No Content"
|
|
}
|
|
```
|
|
|
|
</TabPanel>
|
|
</Tabs>
|
|
|
|
<Tabs scrollable size="small" type="underlined" defaultActiveId="js">
|
|
<TabPanel id="js" label="JavaScript">
|
|
|
|
```ts
|
|
const { data, error } = await supabase
|
|
.from('countries')
|
|
.select()
|
|
```
|
|
|
|
</TabPanel>
|
|
<TabPanel id="result" label="Result">
|
|
|
|
```json
|
|
{
|
|
"data": [
|
|
{
|
|
"id": 1,
|
|
"name": "Australia"
|
|
}
|
|
],
|
|
"status": 200,
|
|
"statusText": "OK"
|
|
}
|
|
```
|
|
|
|
</TabPanel>
|
|
</Tabs>
|
|
hideCodeBlock: true
|
|
isSpotlight: true
|
|
js: |
|
|
```ts
|
|
const { error } = await supabase
|
|
.from('countries')
|
|
.update({ name: 'Australia' })
|
|
.eq('id', 1)
|
|
```
|
|
- id: update-a-record-and-return-it
|
|
name: Update a record and return it
|
|
description: |
|
|
<Tabs scrollable size="small" type="underlined" defaultActiveId="schema">
|
|
<TabPanel id="schema" label="Schema">
|
|
|
|
```sql
|
|
create table
|
|
countries (id int8 primary key, name text);
|
|
|
|
insert into
|
|
countries (id, name)
|
|
values
|
|
(1, 'Taiwan');
|
|
```
|
|
|
|
</TabPanel>
|
|
<TabPanel id="js" label="JavaScript">
|
|
|
|
```ts
|
|
const { data, error } = await supabase
|
|
.from('countries')
|
|
.update({ name: 'Australia' })
|
|
.eq('id', 1)
|
|
.select()
|
|
```
|
|
|
|
</TabPanel>
|
|
<TabPanel id="result" label="Result">
|
|
|
|
```json
|
|
{
|
|
"data": [
|
|
{
|
|
"id": 1,
|
|
"name": "Australia"
|
|
}
|
|
],
|
|
"status": 200,
|
|
"statusText": "OK"
|
|
}
|
|
```
|
|
|
|
</TabPanel>
|
|
</Tabs>
|
|
hideCodeBlock: true
|
|
- id: updating-json-data
|
|
name: Updating JSON data
|
|
description: |
|
|
Postgres offers some
|
|
[operators](/docs/guides/database/json#query-the-jsonb-data) for
|
|
working with JSON data.
|
|
|
|
<Tabs scrollable size="small" type="underlined" defaultActiveId="schema">
|
|
<TabPanel id="schema" label="Schema">
|
|
|
|
```sql
|
|
create table
|
|
users (
|
|
id int8 primary key,
|
|
name text,
|
|
address jsonb
|
|
);
|
|
|
|
insert into
|
|
users (id, name, address)
|
|
values
|
|
(1, 'Michael', '{ "postcode": 90210 }');
|
|
```
|
|
|
|
</TabPanel>
|
|
<TabPanel id="js" label="JavaScript">
|
|
|
|
```ts
|
|
const { data, error } = await supabase
|
|
.from('users')
|
|
.update({
|
|
address: {
|
|
street: 'Melrose Place',
|
|
postcode: 90210
|
|
}
|
|
})
|
|
.eq('address->postcode', 90210)
|
|
.select()
|
|
```
|
|
|
|
</TabPanel>
|
|
<TabPanel id="result" label="Result">
|
|
|
|
```json
|
|
{
|
|
"data": [
|
|
{
|
|
"id": 1,
|
|
"name": "Michael",
|
|
"address": {
|
|
"street": "Melrose Place",
|
|
"postcode": 90210
|
|
}
|
|
}
|
|
],
|
|
"status": 200,
|
|
"statusText": "OK"
|
|
}
|
|
```
|
|
|
|
</TabPanel>
|
|
</Tabs>
|
|
|
|
Currently, it is only possible to update the entire JSON document.
|
|
hideCodeBlock: true
|
|
|
|
- id: upsert()
|
|
title: 'Upsert data: upsert()'
|
|
$ref: '@supabase/postgrest-js.PostgrestQueryBuilder.upsert'
|
|
notes: |
|
|
- Primary keys must be included in `values` to use upsert.
|
|
examples:
|
|
- id: upsert-your-data
|
|
name: Upsert your data
|
|
description: |
|
|
<Tabs scrollable size="small" type="underlined" defaultActiveId="schema">
|
|
<TabPanel id="schema" label="Schema">
|
|
|
|
```sql
|
|
create table
|
|
countries (id int8 primary key, name text);
|
|
|
|
insert into
|
|
countries (id, name)
|
|
values
|
|
(1, 'Afghanistan');
|
|
```
|
|
|
|
</TabPanel>
|
|
<TabPanel id="js" label="JavaScript">
|
|
|
|
```ts
|
|
const { data, error } = await supabase
|
|
.from('countries')
|
|
.upsert({ id: 1, name: 'Albania' })
|
|
.select()
|
|
```
|
|
|
|
</TabPanel>
|
|
<TabPanel id="result" label="Result">
|
|
|
|
```json
|
|
{
|
|
"data": [
|
|
{
|
|
"id": 1,
|
|
"name": "Albania"
|
|
}
|
|
],
|
|
"status": 201,
|
|
"statusText": "Created"
|
|
}
|
|
```
|
|
|
|
</TabPanel>
|
|
</Tabs>
|
|
hideCodeBlock: true
|
|
isSpotlight: true
|
|
js: |
|
|
```ts
|
|
const { data, error } = await supabase
|
|
.from('countries')
|
|
.upsert({ id: 1, name: 'Albania' })
|
|
.select()
|
|
```
|
|
- id: bulk-upsert-your-data
|
|
name: Bulk Upsert your data
|
|
description: |
|
|
<Tabs scrollable size="small" type="underlined" defaultActiveId="schema">
|
|
<TabPanel id="schema" label="Schema">
|
|
|
|
```sql
|
|
create table
|
|
countries (id int8 primary key, name text);
|
|
|
|
insert into
|
|
countries (id, name)
|
|
values
|
|
(1, 'Afghanistan');
|
|
```
|
|
|
|
</TabPanel>
|
|
<TabPanel id="js" label="JavaScript">
|
|
|
|
```ts
|
|
const { data, error } = await supabase
|
|
.from('countries')
|
|
.upsert([
|
|
{ id: 1, name: 'Albania' },
|
|
{ id: 2, name: 'Algeria' },
|
|
])
|
|
.select()
|
|
```
|
|
|
|
</TabPanel>
|
|
<TabPanel id="result" label="Result">
|
|
|
|
```json
|
|
{
|
|
"data": [
|
|
{
|
|
"id": 1,
|
|
"name": "Albania"
|
|
},
|
|
{
|
|
"id": 2,
|
|
"name": "Algeria"
|
|
}
|
|
],
|
|
"status": 201,
|
|
"statusText": "Created"
|
|
}
|
|
```
|
|
|
|
</TabPanel>
|
|
</Tabs>
|
|
hideCodeBlock: true
|
|
- id: upserting-into-tables-with-constraints
|
|
name: Upserting into tables with constraints
|
|
description: |
|
|
In the following query, `upsert()` implicitly uses the `id`
|
|
(primary key) column to determine conflicts. If there is no existing
|
|
row with the same `id`, `upsert()` inserts a new row, which
|
|
will fail in this case as there is already a row with `handle` `"saoirse"`.
|
|
|
|
<Tabs scrollable size="small" type="underlined" defaultActiveId="schema">
|
|
<TabPanel id="schema" label="Schema">
|
|
|
|
```sql
|
|
create table
|
|
users (
|
|
id int8 generated by default as identity primary key,
|
|
handle text not null unique,
|
|
display_name text
|
|
);
|
|
|
|
insert into
|
|
users (id, handle, display_name)
|
|
values
|
|
(1, 'saoirse', null);
|
|
```
|
|
|
|
</TabPanel>
|
|
<TabPanel id="js" label="JavaScript">
|
|
|
|
```ts
|
|
const { data, error } = await supabase
|
|
.from('users')
|
|
.upsert({ id: 42, handle: 'saoirse', display_name: 'Saoirse' })
|
|
.select()
|
|
```
|
|
|
|
</TabPanel>
|
|
<TabPanel id="result" label="Result">
|
|
|
|
```json
|
|
{
|
|
"error": {
|
|
"code": "23505",
|
|
"details": "Key (handle)=(saoirse) already exists.",
|
|
"hint": null,
|
|
"message": "duplicate key value violates unique constraint \"users_handle_key\""
|
|
},
|
|
"status": 409,
|
|
"statusText": "Conflict"
|
|
}
|
|
```
|
|
|
|
</TabPanel>
|
|
</Tabs>
|
|
|
|
Using the `onConflict` option, you can instruct `upsert()` to use
|
|
another column with a unique constraint to determine conflicts:
|
|
|
|
<Tabs scrollable size="small" type="underlined" defaultActiveId="js">
|
|
<TabPanel id="js" label="JavaScript">
|
|
|
|
```ts
|
|
await supabase
|
|
.from('users')
|
|
.upsert(
|
|
{ id: 42, handle: 'saoirse', display_name: 'Saoirse' },
|
|
{ onConflict: 'handle' },
|
|
)
|
|
const { data, error } = await supabase
|
|
.from('users')
|
|
.select()
|
|
```
|
|
|
|
</TabPanel>
|
|
<TabPanel id="result" label="Result">
|
|
|
|
```json
|
|
{
|
|
"data": [
|
|
{
|
|
"id": 42,
|
|
"handle": "saoirse",
|
|
"display_name": "Saoirse"
|
|
}
|
|
],
|
|
"status": 200,
|
|
"statusText": "OK"
|
|
}
|
|
```
|
|
|
|
</TabPanel>
|
|
</Tabs>
|
|
hideCodeBlock: true
|
|
|
|
- id: delete()
|
|
title: 'Delete data: delete()'
|
|
$ref: '@supabase/postgrest-js.PostgrestQueryBuilder.delete'
|
|
notes: |
|
|
- `delete()` should always be combined with [filters](/docs/reference/javascript/using-filters) to target the item(s) you wish to delete.
|
|
- If you use `delete()` with filters and you have
|
|
[RLS](/docs/learn/auth-deep-dive/auth-row-level-security) enabled, only
|
|
rows visible through `SELECT` policies are deleted. Note that by default
|
|
no rows are visible, so you need at least one `SELECT`/`ALL` policy that
|
|
makes the rows visible.
|
|
examples:
|
|
- id: delete-records
|
|
name: Delete records
|
|
description: |
|
|
<Tabs scrollable size="small" type="underlined" defaultActiveId="schema">
|
|
<TabPanel id="schema" label="Schema">
|
|
|
|
```sql
|
|
create table
|
|
countries (id int8 primary key, name text);
|
|
|
|
insert into
|
|
countries (id, name)
|
|
values
|
|
(1, 'Spain');
|
|
```
|
|
|
|
</TabPanel>
|
|
<TabPanel id="js" label="JavaScript">
|
|
|
|
```ts
|
|
const { error } = await supabase
|
|
.from('countries')
|
|
.delete()
|
|
.eq('id', 1)
|
|
```
|
|
|
|
</TabPanel>
|
|
<TabPanel id="result" label="Result">
|
|
|
|
```json
|
|
{
|
|
"status": 204,
|
|
"statusText": "No Content"
|
|
}
|
|
```
|
|
|
|
</TabPanel>
|
|
</Tabs>
|
|
|
|
<Tabs scrollable size="small" type="underlined" defaultActiveId="js">
|
|
<TabPanel id="js" label="JavaScript">
|
|
|
|
```ts
|
|
const { data, error } = await supabase
|
|
.from('countries')
|
|
.select()
|
|
```
|
|
|
|
</TabPanel>
|
|
<TabPanel id="result" label="Result">
|
|
|
|
```json
|
|
{
|
|
"data": [],
|
|
"status": 200,
|
|
"statusText": "OK"
|
|
}
|
|
```
|
|
|
|
</TabPanel>
|
|
</Tabs>
|
|
hideCodeBlock: true
|
|
isSpotlight: true
|
|
js: |
|
|
```ts
|
|
const { error } = await supabase
|
|
.from('countries')
|
|
.delete()
|
|
.eq('id', 1)
|
|
```
|
|
|
|
- id: rpc()
|
|
title: 'Postgres functions: rpc()'
|
|
description: |
|
|
You can call Postgres functions as _Remote Procedure Calls_, logic in your database that you can execute from anywhere.
|
|
Functions are useful when the logic rarely changes—like for password resets and updates.
|
|
|
|
```sql
|
|
create or replace function hello_world() returns text as $$
|
|
select 'Hello world';
|
|
$$ language sql;
|
|
```
|
|
$ref: '@supabase/postgrest-js.PostgrestClient.rpc'
|
|
examples:
|
|
- id: call-a-postgres-function-without-arguments
|
|
name: Call a Postgres function without arguments
|
|
description: |
|
|
<Tabs scrollable size="small" type="underlined" defaultActiveId="schema">
|
|
<TabPanel id="schema" label="Schema">
|
|
|
|
```sql
|
|
create function hello_world() returns text as $$
|
|
select 'Hello world';
|
|
$$ language sql;
|
|
```
|
|
|
|
</TabPanel>
|
|
<TabPanel id="js" label="JavaScript">
|
|
|
|
```ts
|
|
const { data, error } = await supabase.rpc('hello_world')
|
|
```
|
|
|
|
</TabPanel>
|
|
<TabPanel id="result" label="Result">
|
|
|
|
```json
|
|
{
|
|
"data": "Hello world",
|
|
"status": 200,
|
|
"statusText": "OK"
|
|
}
|
|
```
|
|
|
|
</TabPanel>
|
|
</Tabs>
|
|
hideCodeBlock: true
|
|
isSpotlight: true
|
|
js: |
|
|
```ts
|
|
const { data, error } = await supabase.rpc('hello_world')
|
|
```
|
|
- id: call-a-postgres-function-with-arguments
|
|
name: Call a Postgres function with arguments
|
|
description: |
|
|
<Tabs scrollable size="small" type="underlined" defaultActiveId="schema">
|
|
<TabPanel id="schema" label="Schema">
|
|
|
|
```sql
|
|
create function echo(say text) returns text as $$
|
|
select say;
|
|
$$ language sql;
|
|
```
|
|
|
|
</TabPanel>
|
|
<TabPanel id="js" label="JavaScript">
|
|
|
|
```ts
|
|
const { data, error } = await supabase.rpc('echo', { say: '👋' })
|
|
```
|
|
|
|
</TabPanel>
|
|
<TabPanel id="result" label="Result">
|
|
|
|
```json
|
|
{
|
|
"data": "👋",
|
|
"status": 200,
|
|
"statusText": "OK"
|
|
}
|
|
```
|
|
|
|
</TabPanel>
|
|
</Tabs>
|
|
hideCodeBlock: true
|
|
- id: bulk-processing
|
|
name: Bulk processing
|
|
description: |
|
|
You can process large payloads by passing in an array as an argument:
|
|
|
|
<Tabs scrollable size="small" type="underlined" defaultActiveId="schema">
|
|
<TabPanel id="schema" label="Schema">
|
|
|
|
```sql
|
|
create function add_one_each(arr int[]) returns int[] as $$
|
|
select array_agg(n + 1) from unnest(arr) as n;
|
|
$$ language sql;
|
|
```
|
|
|
|
</TabPanel>
|
|
<TabPanel id="js" label="JavaScript">
|
|
|
|
```ts
|
|
const { data, error } = await supabase.rpc('add_one_each', { arr: [1, 2, 3] })
|
|
```
|
|
|
|
</TabPanel>
|
|
<TabPanel id="result" label="Result">
|
|
|
|
```json
|
|
{
|
|
"data": [
|
|
2,
|
|
3,
|
|
4
|
|
],
|
|
"status": 200,
|
|
"statusText": "OK"
|
|
}
|
|
```
|
|
|
|
</TabPanel>
|
|
</Tabs>
|
|
hideCodeBlock: true
|
|
- id: call-a-postgres-function-with-filters
|
|
name: Call a Postgres function with filters
|
|
description: |
|
|
Postgres functions that return tables can also be combined with
|
|
[Filters](/docs/reference/javascript/using-filters) and
|
|
[Modifiers](/docs/reference/javascript/using-modifiers).
|
|
|
|
<Tabs scrollable size="small" type="underlined" defaultActiveId="schema">
|
|
<TabPanel id="schema" label="Schema">
|
|
|
|
```sql
|
|
create table
|
|
countries (id int8 primary key, name text);
|
|
|
|
insert into
|
|
countries (id, name)
|
|
values
|
|
(1, 'France'),
|
|
(2, 'United Kingdom');
|
|
|
|
create function list_stored_countries() returns setof countries as $$
|
|
select * from countries;
|
|
$$ language sql;
|
|
```
|
|
|
|
</TabPanel>
|
|
<TabPanel id="js" label="JavaScript">
|
|
|
|
```ts
|
|
const { data, error } = await supabase
|
|
.rpc('list_stored_countries')
|
|
.eq('id', 1)
|
|
.single()
|
|
```
|
|
|
|
</TabPanel>
|
|
<TabPanel id="result" label="Result">
|
|
|
|
```json
|
|
{
|
|
"data": {
|
|
"id": 1,
|
|
"name": "France"
|
|
},
|
|
"status": 200,
|
|
"statusText": "OK"
|
|
}
|
|
```
|
|
|
|
</TabPanel>
|
|
</Tabs>
|
|
hideCodeBlock: true
|
|
|
|
- id: Using Filters
|
|
description: |
|
|
Filters allow you to only return rows that match certain conditions.
|
|
|
|
Filters can be used on `select()`, `update()`, `upsert()`, and `delete()` queries.
|
|
|
|
If a Postgres function returns a table response, you can also apply filters.
|
|
|
|
### Applying Filters
|
|
|
|
Filters must be applied after any of `select()`, `update()`, `upsert()`,
|
|
`delete()`, and `rpc()` and before
|
|
[modifiers](/docs/reference/javascript/using-modifiers).
|
|
|
|
```ts
|
|
const { data, error } = await supabase
|
|
.from('cities')
|
|
.select('name, country_id')
|
|
.eq('name', 'The Shire') // Correct
|
|
|
|
const { data, error } = await supabase
|
|
.from('cities')
|
|
.eq('name', 'The Shire') // Incorrect
|
|
.select('name, country_id')
|
|
```
|
|
|
|
### Chaining
|
|
|
|
Filters can be chained together to produce advanced queries. For example,
|
|
to query cities with population between 1,000 and 10,000:
|
|
|
|
```ts
|
|
const { data, error } = await supabase
|
|
.from('cities')
|
|
.select('name, country_id')
|
|
.gte('population', 1000)
|
|
.lt('population', 10000)
|
|
```
|
|
|
|
### Conditional Chaining
|
|
|
|
Filters can be built up one step at a time and then executed. For example:
|
|
|
|
```ts
|
|
const filterByName = null
|
|
const filterPopLow = 1000
|
|
const filterPopHigh = 10000
|
|
|
|
let query = supabase
|
|
.from('cities')
|
|
.select('name, country_id')
|
|
|
|
if (filterByName) { query = query.eq('name', filterByName) }
|
|
if (filterPopLow) { query = query.gte('population', filterPopLow) }
|
|
if (filterPopHigh) { query = query.lt('population', filterPopHigh) }
|
|
|
|
const { data, error } = await query
|
|
```
|
|
|
|
### Filter by values within a JSON column
|
|
|
|
<Tabs scrollable size="small" type="underlined" defaultActiveId="schema">
|
|
<TabPanel id="schema" label="Schema">
|
|
|
|
```sql
|
|
create table
|
|
users (
|
|
id int8 primary key,
|
|
name text,
|
|
address jsonb
|
|
);
|
|
|
|
insert into
|
|
users (id, name, address)
|
|
values
|
|
(1, 'Michael', '{ "postcode": 90210 }'),
|
|
(2, 'Jane', null);
|
|
```
|
|
|
|
</TabPanel>
|
|
<TabPanel id="js" label="JavaScript">
|
|
|
|
```ts
|
|
const { data, error } = await supabase
|
|
.from('users')
|
|
.select()
|
|
.eq('address->postcode', 90210)
|
|
```
|
|
|
|
</TabPanel>
|
|
<TabPanel id="result" label="Result">
|
|
|
|
```json
|
|
{
|
|
"data": [
|
|
{
|
|
"id": 1,
|
|
"name": "Michael",
|
|
"address": {
|
|
"postcode": 90210
|
|
}
|
|
}
|
|
],
|
|
"status": 200,
|
|
"statusText": "OK"
|
|
}
|
|
```
|
|
|
|
</TabPanel>
|
|
</Tabs>
|
|
|
|
### Filter Referenced Tables
|
|
|
|
You can filter on referenced tables in your `select()` query using dot
|
|
notation:
|
|
|
|
<Tabs scrollable size="small" type="underlined" defaultActiveId="schema">
|
|
<TabPanel id="schema" label="Schema">
|
|
|
|
```sql
|
|
create table
|
|
countries (id int8 primary key, name text);
|
|
create table
|
|
cities (
|
|
id int8 primary key,
|
|
country_id int8 not null references countries,
|
|
name text
|
|
);
|
|
|
|
insert into
|
|
countries (id, name)
|
|
values
|
|
(1, 'Germany'),
|
|
(2, 'Indonesia');
|
|
insert into
|
|
cities (id, country_id, name)
|
|
values
|
|
(1, 2, 'Bali'),
|
|
(2, 1, 'Munich');
|
|
```
|
|
|
|
</TabPanel>
|
|
<TabPanel id="js" label="JavaScript">
|
|
|
|
```ts
|
|
const { data, error } = await supabase
|
|
.from('countries')
|
|
.select(`
|
|
name,
|
|
cities!inner (
|
|
name
|
|
)
|
|
`)
|
|
.eq('cities.name', 'Bali')
|
|
```
|
|
|
|
</TabPanel>
|
|
<TabPanel id="result" label="Result">
|
|
|
|
```json
|
|
{
|
|
"data": [
|
|
{
|
|
"name": "Indonesia",
|
|
"cities": [
|
|
{
|
|
"name": "Bali"
|
|
}
|
|
]
|
|
}
|
|
],
|
|
"status": 200,
|
|
"statusText": "OK"
|
|
}
|
|
```
|
|
|
|
</TabPanel>
|
|
</Tabs>
|
|
|
|
- id: eq()
|
|
$ref: '@supabase/postgrest-js.PostgrestFilterBuilder.eq'
|
|
examples:
|
|
- id: with`select()`
|
|
name: With `select()`
|
|
description: |
|
|
<Tabs scrollable size="small" type="underlined" defaultActiveId="schema">
|
|
<TabPanel id="schema" label="Schema">
|
|
|
|
```sql
|
|
create table
|
|
countries (id int8 primary key, name text);
|
|
|
|
insert into
|
|
countries (id, name)
|
|
values
|
|
(1, 'Afghanistan'),
|
|
(2, 'Albania'),
|
|
(3, 'Algeria');
|
|
```
|
|
|
|
</TabPanel>
|
|
<TabPanel id="js" label="JavaScript">
|
|
|
|
```ts
|
|
const { data, error } = await supabase
|
|
.from('countries')
|
|
.select()
|
|
.eq('name', 'Albania')
|
|
```
|
|
|
|
</TabPanel>
|
|
<TabPanel id="result" label="Result">
|
|
|
|
```json
|
|
{
|
|
"data": [
|
|
{
|
|
"id": 2,
|
|
"name": "Albania"
|
|
}
|
|
],
|
|
"status": 200,
|
|
"statusText": "OK"
|
|
}
|
|
```
|
|
|
|
</TabPanel>
|
|
</Tabs>
|
|
hideCodeBlock: true
|
|
isSpotlight: true
|
|
js: |
|
|
```ts
|
|
const { data, error } = await supabase
|
|
.from('countries')
|
|
.select()
|
|
.eq('name', 'Albania')
|
|
```
|
|
|
|
- id: neq()
|
|
$ref: '@supabase/postgrest-js.PostgrestFilterBuilder.neq'
|
|
examples:
|
|
- id: with`select()`
|
|
name: With `select()`
|
|
description: |
|
|
<Tabs scrollable size="small" type="underlined" defaultActiveId="schema">
|
|
<TabPanel id="schema" label="Schema">
|
|
|
|
```sql
|
|
create table
|
|
countries (id int8 primary key, name text);
|
|
|
|
insert into
|
|
countries (id, name)
|
|
values
|
|
(1, 'Afghanistan'),
|
|
(2, 'Albania'),
|
|
(3, 'Algeria');
|
|
```
|
|
|
|
</TabPanel>
|
|
<TabPanel id="js" label="JavaScript">
|
|
|
|
```ts
|
|
const { data, error } = await supabase
|
|
.from('countries')
|
|
.select()
|
|
.neq('name', 'Albania')
|
|
```
|
|
|
|
</TabPanel>
|
|
<TabPanel id="result" label="Result">
|
|
|
|
```json
|
|
{
|
|
"data": [
|
|
{
|
|
"id": 1,
|
|
"name": "Afghanistan"
|
|
},
|
|
{
|
|
"id": 3,
|
|
"name": "Algeria"
|
|
}
|
|
],
|
|
"status": 200,
|
|
"statusText": "OK"
|
|
}
|
|
```
|
|
|
|
</TabPanel>
|
|
</Tabs>
|
|
hideCodeBlock: true
|
|
isSpotlight: true
|
|
js: |
|
|
```ts
|
|
const { data, error } = await supabase
|
|
.from('countries')
|
|
.select()
|
|
.neq('name', 'Albania')
|
|
```
|
|
|
|
- id: gt()
|
|
$ref: '@supabase/postgrest-js.PostgrestFilterBuilder.gt'
|
|
examples:
|
|
- id: with`select()`
|
|
name: With `select()`
|
|
description: |
|
|
<Tabs scrollable size="small" type="underlined" defaultActiveId="schema">
|
|
<TabPanel id="schema" label="Schema">
|
|
|
|
```sql
|
|
create table
|
|
countries (id int8 primary key, name text);
|
|
|
|
insert into
|
|
countries (id, name)
|
|
values
|
|
(1, 'Afghanistan'),
|
|
(2, 'Albania'),
|
|
(3, 'Algeria');
|
|
```
|
|
|
|
</TabPanel>
|
|
<TabPanel id="js" label="JavaScript">
|
|
|
|
```ts
|
|
const { data, error } = await supabase
|
|
.from('countries')
|
|
.select()
|
|
.gt('id', 2)
|
|
```
|
|
|
|
</TabPanel>
|
|
<TabPanel id="result" label="Result">
|
|
|
|
```json
|
|
{
|
|
"data": [
|
|
{
|
|
"id": 3,
|
|
"name": "Algeria"
|
|
}
|
|
],
|
|
"status": 200,
|
|
"statusText": "OK"
|
|
}
|
|
```
|
|
|
|
</TabPanel>
|
|
</Tabs>
|
|
hideCodeBlock: true
|
|
isSpotlight: true
|
|
js: |
|
|
```ts
|
|
const { data, error } = await supabase
|
|
.from('countries')
|
|
.select()
|
|
.gt('id', 2)
|
|
```
|
|
|
|
- id: gte()
|
|
$ref: '@supabase/postgrest-js.PostgrestFilterBuilder.gte'
|
|
examples:
|
|
- id: with`select()`
|
|
name: With `select()`
|
|
description: |
|
|
<Tabs scrollable size="small" type="underlined" defaultActiveId="schema">
|
|
<TabPanel id="schema" label="Schema">
|
|
|
|
```sql
|
|
create table
|
|
countries (id int8 primary key, name text);
|
|
|
|
insert into
|
|
countries (id, name)
|
|
values
|
|
(1, 'Afghanistan'),
|
|
(2, 'Albania'),
|
|
(3, 'Algeria');
|
|
```
|
|
|
|
</TabPanel>
|
|
<TabPanel id="js" label="JavaScript">
|
|
|
|
```ts
|
|
const { data, error } = await supabase
|
|
.from('countries')
|
|
.select()
|
|
.gte('id', 2)
|
|
```
|
|
|
|
</TabPanel>
|
|
<TabPanel id="result" label="Result">
|
|
|
|
```json
|
|
{
|
|
"data": [
|
|
{
|
|
"id": 2,
|
|
"name": "Albania"
|
|
},
|
|
{
|
|
"id": 3,
|
|
"name": "Algeria"
|
|
}
|
|
],
|
|
"status": 200,
|
|
"statusText": "OK"
|
|
}
|
|
```
|
|
|
|
</TabPanel>
|
|
</Tabs>
|
|
hideCodeBlock: true
|
|
isSpotlight: true
|
|
js: |
|
|
```ts
|
|
const { data, error } = await supabase
|
|
.from('countries')
|
|
.select()
|
|
.gte('id', 2)
|
|
```
|
|
|
|
- id: lt()
|
|
$ref: '@supabase/postgrest-js.PostgrestFilterBuilder.lt'
|
|
examples:
|
|
- id: with`select()`
|
|
name: With `select()`
|
|
description: |
|
|
<Tabs scrollable size="small" type="underlined" defaultActiveId="schema">
|
|
<TabPanel id="schema" label="Schema">
|
|
|
|
```sql
|
|
create table
|
|
countries (id int8 primary key, name text);
|
|
|
|
insert into
|
|
countries (id, name)
|
|
values
|
|
(1, 'Afghanistan'),
|
|
(2, 'Albania'),
|
|
(3, 'Algeria');
|
|
```
|
|
|
|
</TabPanel>
|
|
<TabPanel id="js" label="JavaScript">
|
|
|
|
```ts
|
|
const { data, error } = await supabase
|
|
.from('countries')
|
|
.select()
|
|
.lt('id', 2)
|
|
```
|
|
|
|
</TabPanel>
|
|
<TabPanel id="result" label="Result">
|
|
|
|
```json
|
|
{
|
|
"data": [
|
|
{
|
|
"id": 1,
|
|
"name": "Afghanistan"
|
|
}
|
|
],
|
|
"status": 200,
|
|
"statusText": "OK"
|
|
}
|
|
```
|
|
|
|
</TabPanel>
|
|
</Tabs>
|
|
hideCodeBlock: true
|
|
isSpotlight: true
|
|
js: |
|
|
```ts
|
|
const { data, error } = await supabase
|
|
.from('countries')
|
|
.select()
|
|
.lt('id', 2)
|
|
```
|
|
|
|
- id: lte()
|
|
$ref: '@supabase/postgrest-js.PostgrestFilterBuilder.lte'
|
|
examples:
|
|
- id: with`select()`
|
|
name: With `select()`
|
|
description: |
|
|
<Tabs scrollable size="small" type="underlined" defaultActiveId="schema">
|
|
<TabPanel id="schema" label="Schema">
|
|
|
|
```sql
|
|
create table
|
|
countries (id int8 primary key, name text);
|
|
|
|
insert into
|
|
countries (id, name)
|
|
values
|
|
(1, 'Afghanistan'),
|
|
(2, 'Albania'),
|
|
(3, 'Algeria');
|
|
```
|
|
|
|
</TabPanel>
|
|
<TabPanel id="js" label="JavaScript">
|
|
|
|
```ts
|
|
const { data, error } = await supabase
|
|
.from('countries')
|
|
.select()
|
|
.lte('id', 2)
|
|
```
|
|
|
|
</TabPanel>
|
|
<TabPanel id="result" label="Result">
|
|
|
|
```json
|
|
{
|
|
"data": [
|
|
{
|
|
"id": 1,
|
|
"name": "Afghanistan"
|
|
},
|
|
{
|
|
"id": 2,
|
|
"name": "Albania"
|
|
}
|
|
],
|
|
"status": 200,
|
|
"statusText": "OK"
|
|
}
|
|
```
|
|
|
|
</TabPanel>
|
|
</Tabs>
|
|
hideCodeBlock: true
|
|
isSpotlight: true
|
|
js: |
|
|
```ts
|
|
const { data, error } = await supabase
|
|
.from('countries')
|
|
.select()
|
|
.lte('id', 2)
|
|
```
|
|
|
|
- id: like()
|
|
$ref: '@supabase/postgrest-js.PostgrestFilterBuilder.like'
|
|
examples:
|
|
- id: with`select()`
|
|
name: With `select()`
|
|
description: |
|
|
<Tabs scrollable size="small" type="underlined" defaultActiveId="schema">
|
|
<TabPanel id="schema" label="Schema">
|
|
|
|
```sql
|
|
create table
|
|
countries (id int8 primary key, name text);
|
|
|
|
insert into
|
|
countries (id, name)
|
|
values
|
|
(1, 'Afghanistan'),
|
|
(2, 'Albania'),
|
|
(3, 'Algeria');
|
|
```
|
|
|
|
</TabPanel>
|
|
<TabPanel id="js" label="JavaScript">
|
|
|
|
```ts
|
|
const { data, error } = await supabase
|
|
.from('countries')
|
|
.select()
|
|
.like('name', '%Alba%')
|
|
```
|
|
|
|
</TabPanel>
|
|
<TabPanel id="result" label="Result">
|
|
|
|
```json
|
|
{
|
|
"data": [
|
|
{
|
|
"id": 2,
|
|
"name": "Albania"
|
|
}
|
|
],
|
|
"status": 200,
|
|
"statusText": "OK"
|
|
}
|
|
```
|
|
|
|
</TabPanel>
|
|
</Tabs>
|
|
hideCodeBlock: true
|
|
isSpotlight: true
|
|
js: |
|
|
```ts
|
|
const { data, error } = await supabase
|
|
.from('countries')
|
|
.select()
|
|
.like('name', '%Alba%')
|
|
```
|
|
|
|
- id: ilike()
|
|
$ref: '@supabase/postgrest-js.PostgrestFilterBuilder.ilike'
|
|
examples:
|
|
- id: with`select()`
|
|
name: With `select()`
|
|
description: |
|
|
<Tabs scrollable size="small" type="underlined" defaultActiveId="schema">
|
|
<TabPanel id="schema" label="Schema">
|
|
|
|
```sql
|
|
create table
|
|
countries (id int8 primary key, name text);
|
|
|
|
insert into
|
|
countries (id, name)
|
|
values
|
|
(1, 'Afghanistan'),
|
|
(2, 'Albania'),
|
|
(3, 'Algeria');
|
|
```
|
|
|
|
</TabPanel>
|
|
<TabPanel id="js" label="JavaScript">
|
|
|
|
```ts
|
|
const { data, error } = await supabase
|
|
.from('countries')
|
|
.select()
|
|
.like('name', '%alba%')
|
|
```
|
|
|
|
</TabPanel>
|
|
<TabPanel id="result" label="Result">
|
|
|
|
```json
|
|
{
|
|
"data": [
|
|
{
|
|
"id": 2,
|
|
"name": "Albania"
|
|
}
|
|
],
|
|
"status": 200,
|
|
"statusText": "OK"
|
|
}
|
|
```
|
|
|
|
</TabPanel>
|
|
</Tabs>
|
|
hideCodeBlock: true
|
|
isSpotlight: true
|
|
js: |
|
|
```ts
|
|
const { data, error } = await supabase
|
|
.from('countries')
|
|
.select()
|
|
.like('name', '%alba%')
|
|
```
|
|
|
|
- id: is()
|
|
$ref: '@supabase/postgrest-js.PostgrestFilterBuilder.is'
|
|
examples:
|
|
- id: checking-nullness
|
|
name: Checking nullness
|
|
description: |
|
|
Using the `eq()` filter doesn't work when filtering for `null`:
|
|
|
|
<Tabs scrollable size="small" type="underlined" defaultActiveId="schema">
|
|
<TabPanel id="schema" label="Schema">
|
|
|
|
```sql
|
|
create table
|
|
countries (id int8 primary key, name text);
|
|
|
|
insert into
|
|
countries (id, name)
|
|
values
|
|
(1, 'null'),
|
|
(2, null);
|
|
```
|
|
|
|
</TabPanel>
|
|
<TabPanel id="js" label="JavaScript">
|
|
|
|
```ts
|
|
const { data, error } = await supabase
|
|
.from('countries')
|
|
.select()
|
|
.eq('name', null)
|
|
```
|
|
|
|
</TabPanel>
|
|
<TabPanel id="result" label="Result">
|
|
|
|
```json
|
|
{
|
|
"data": [
|
|
{
|
|
"id": 1,
|
|
"name": "null"
|
|
}
|
|
],
|
|
"status": 200,
|
|
"statusText": "OK"
|
|
}
|
|
```
|
|
|
|
</TabPanel>
|
|
</Tabs>
|
|
|
|
Instead, you need to use `is()`:
|
|
|
|
<Tabs scrollable size="small" type="underlined" defaultActiveId="js">
|
|
<TabPanel id="js" label="JavaScript">
|
|
|
|
```ts
|
|
const { data, error } = await supabase
|
|
.from('countries')
|
|
.select()
|
|
.is('name', null)
|
|
```
|
|
|
|
</TabPanel>
|
|
<TabPanel id="result" label="Result">
|
|
|
|
```json
|
|
{
|
|
"data": [
|
|
{
|
|
"id": 2,
|
|
"name": null
|
|
}
|
|
],
|
|
"status": 200,
|
|
"statusText": "OK"
|
|
}
|
|
```
|
|
|
|
</TabPanel>
|
|
</Tabs>
|
|
hideCodeBlock: true
|
|
isSpotlight: true
|
|
js: |
|
|
```ts
|
|
const { data, error } = await supabase
|
|
.from('countries')
|
|
.select()
|
|
.is('name', null)
|
|
```
|
|
|
|
- id: in()
|
|
$ref: '@supabase/postgrest-js.PostgrestFilterBuilder.in'
|
|
examples:
|
|
- id: with`select()`
|
|
name: With `select()`
|
|
description: |
|
|
<Tabs scrollable size="small" type="underlined" defaultActiveId="schema">
|
|
<TabPanel id="schema" label="Schema">
|
|
|
|
```sql
|
|
create table
|
|
countries (id int8 primary key, name text);
|
|
|
|
insert into
|
|
countries (id, name)
|
|
values
|
|
(1, 'Afghanistan'),
|
|
(2, 'Albania'),
|
|
(3, 'Algeria');
|
|
```
|
|
|
|
</TabPanel>
|
|
<TabPanel id="js" label="JavaScript">
|
|
|
|
```ts
|
|
const { data, error } = await supabase
|
|
.from('countries')
|
|
.select()
|
|
.in('name', ['Albania', 'Algeria'])
|
|
```
|
|
|
|
</TabPanel>
|
|
<TabPanel id="result" label="Result">
|
|
|
|
```json
|
|
{
|
|
"data": [
|
|
{
|
|
"id": 2,
|
|
"name": "Albania"
|
|
},
|
|
{
|
|
"id": 3,
|
|
"name": "Algeria"
|
|
}
|
|
],
|
|
"status": 200,
|
|
"statusText": "OK"
|
|
}
|
|
```
|
|
|
|
</TabPanel>
|
|
</Tabs>
|
|
hideCodeBlock: true
|
|
isSpotlight: true
|
|
js: |
|
|
```ts
|
|
const { data, error } = await supabase
|
|
.from('countries')
|
|
.select()
|
|
.in('name', ['Albania', 'Algeria'])
|
|
```
|
|
|
|
- id: contains()
|
|
$ref: '@supabase/postgrest-js.PostgrestFilterBuilder.contains'
|
|
examples:
|
|
- id: on-array-columns
|
|
name: On array columns
|
|
description: |
|
|
<Tabs scrollable size="small" type="underlined" defaultActiveId="schema">
|
|
<TabPanel id="schema" label="Schema">
|
|
|
|
```sql
|
|
create table
|
|
issues (
|
|
id int8 primary key,
|
|
title text,
|
|
tags text[]
|
|
);
|
|
|
|
insert into
|
|
issues (id, title, tags)
|
|
values
|
|
(1, 'Cache invalidation is not working', array['is:open', 'severity:high', 'priority:low']),
|
|
(2, 'Use better names', array['is:open', 'severity:low', 'priority:medium']);
|
|
```
|
|
|
|
</TabPanel>
|
|
<TabPanel id="js" label="JavaScript">
|
|
|
|
```ts
|
|
const { data, error } = await supabase
|
|
.from('issues')
|
|
.select('title')
|
|
.contains('tags', ['is:open', 'severity:high'])
|
|
```
|
|
|
|
</TabPanel>
|
|
<TabPanel id="result" label="Result">
|
|
|
|
```json
|
|
{
|
|
"data": [
|
|
{
|
|
"title": "Cache invalidation is not working"
|
|
}
|
|
],
|
|
"status": 200,
|
|
"statusText": "OK"
|
|
}
|
|
```
|
|
|
|
</TabPanel>
|
|
</Tabs>
|
|
hideCodeBlock: true
|
|
isSpotlight: true
|
|
js: |
|
|
```ts
|
|
const { data, error } = await supabase
|
|
.from('users')
|
|
.select()
|
|
.contains('name', ['is:online', 'faction:red'])
|
|
```
|
|
- id: on-range-columns
|
|
name: On range columns
|
|
description: |
|
|
Postgres supports a number of [range
|
|
types](https://www.postgresql.org/docs/current/rangetypes.html). You
|
|
can filter on range columns using the string representation of range
|
|
values.
|
|
|
|
<Tabs scrollable size="small" type="underlined" defaultActiveId="schema">
|
|
<TabPanel id="schema" label="Schema">
|
|
|
|
```sql
|
|
create table
|
|
reservations (
|
|
id int8 primary key,
|
|
room_name text,
|
|
during tsrange
|
|
);
|
|
|
|
insert into
|
|
reservations (id, room_name, during)
|
|
values
|
|
(1, 'Emerald', '[2000-01-01 13:00, 2000-01-01 15:00)'),
|
|
(2, 'Topaz', '[2000-01-02 09:00, 2000-01-02 10:00)');
|
|
```
|
|
|
|
</TabPanel>
|
|
<TabPanel id="js" label="JavaScript">
|
|
|
|
```ts
|
|
const { data, error } = await supabase
|
|
.from('reservations')
|
|
.select()
|
|
.contains('during', '[2000-01-01 13:00, 2000-01-01 13:30)')
|
|
```
|
|
|
|
</TabPanel>
|
|
<TabPanel id="result" label="Result">
|
|
|
|
```json
|
|
{
|
|
"data": [
|
|
{
|
|
"id": 1,
|
|
"room_name": "Emerald",
|
|
"during": "[\"2000-01-01 13:00:00\",\"2000-01-01 15:00:00\")"
|
|
}
|
|
],
|
|
"status": 200,
|
|
"statusText": "OK"
|
|
}
|
|
```
|
|
|
|
</TabPanel>
|
|
</Tabs>
|
|
hideCodeBlock: true
|
|
- id: on`jsonb`columns
|
|
name: On `jsonb` columns
|
|
description: |
|
|
<Tabs scrollable size="small" type="underlined" defaultActiveId="schema">
|
|
<TabPanel id="schema" label="Schema">
|
|
|
|
```sql
|
|
create table
|
|
users (
|
|
id int8 primary key,
|
|
name text,
|
|
address jsonb
|
|
);
|
|
|
|
insert into
|
|
users (id, name, address)
|
|
values
|
|
(1, 'Michael', '{ "postcode": 90210, "street": "Melrose Place" }'),
|
|
(2, 'Jane', '{}');
|
|
```
|
|
|
|
</TabPanel>
|
|
<TabPanel id="js" label="JavaScript">
|
|
|
|
```ts
|
|
const { data, error } = await supabase
|
|
.from('users')
|
|
.select('name')
|
|
.contains('address', { postcode: 90210 })
|
|
```
|
|
|
|
</TabPanel>
|
|
<TabPanel id="result" label="Result">
|
|
|
|
```json
|
|
{
|
|
"data": [
|
|
{
|
|
"name": "Michael"
|
|
}
|
|
],
|
|
"status": 200,
|
|
"statusText": "OK"
|
|
}
|
|
```
|
|
|
|
</TabPanel>
|
|
</Tabs>
|
|
hideCodeBlock: true
|
|
|
|
- id: containedBy()
|
|
$ref: '@supabase/postgrest-js.PostgrestFilterBuilder.containedBy'
|
|
examples:
|
|
- id: on-array-columns
|
|
name: On array columns
|
|
description: |
|
|
<Tabs scrollable size="small" type="underlined" defaultActiveId="schema">
|
|
<TabPanel id="schema" label="Schema">
|
|
|
|
```sql
|
|
create table
|
|
classes (
|
|
id int8 primary key,
|
|
name text,
|
|
days text[]
|
|
);
|
|
|
|
insert into
|
|
classes (id, name, days)
|
|
values
|
|
(1, 'Chemistry', array['monday', 'friday']),
|
|
(2, 'History', array['monday', 'wednesday', 'thursday']);
|
|
```
|
|
|
|
</TabPanel>
|
|
<TabPanel id="js" label="JavaScript">
|
|
|
|
```ts
|
|
const { data, error } = await supabase
|
|
.from('classes')
|
|
.select('name')
|
|
.containedBy('days', ['monday', 'tuesday', 'wednesday', 'friday'])
|
|
```
|
|
|
|
</TabPanel>
|
|
<TabPanel id="result" label="Result">
|
|
|
|
```json
|
|
{
|
|
"data": [
|
|
{
|
|
"name": "Chemistry"
|
|
}
|
|
],
|
|
"status": 200,
|
|
"statusText": "OK"
|
|
}
|
|
```
|
|
|
|
</TabPanel>
|
|
</Tabs>
|
|
hideCodeBlock: true
|
|
isSpotlight: true
|
|
js: |
|
|
```ts
|
|
const { data, error } = await supabase
|
|
.from('classes')
|
|
.select('name')
|
|
.containedBy('days', ['monday', 'tuesday', 'wednesday', 'friday'])
|
|
```
|
|
- id: on-range-columns
|
|
name: On range columns
|
|
description: |
|
|
Postgres supports a number of [range
|
|
types](https://www.postgresql.org/docs/current/rangetypes.html). You
|
|
can filter on range columns using the string representation of range
|
|
values.
|
|
|
|
<Tabs scrollable size="small" type="underlined" defaultActiveId="schema">
|
|
<TabPanel id="schema" label="Schema">
|
|
|
|
```sql
|
|
create table
|
|
reservations (
|
|
id int8 primary key,
|
|
room_name text,
|
|
during tsrange
|
|
);
|
|
|
|
insert into
|
|
reservations (id, room_name, during)
|
|
values
|
|
(1, 'Emerald', '[2000-01-01 13:00, 2000-01-01 15:00)'),
|
|
(2, 'Topaz', '[2000-01-02 09:00, 2000-01-02 10:00)');
|
|
```
|
|
|
|
</TabPanel>
|
|
<TabPanel id="js" label="JavaScript">
|
|
|
|
```ts
|
|
const { data, error } = await supabase
|
|
.from('reservations')
|
|
.select()
|
|
.containedBy('during', '[2000-01-01 00:00, 2000-01-01 23:59)')
|
|
```
|
|
|
|
</TabPanel>
|
|
<TabPanel id="result" label="Result">
|
|
|
|
```json
|
|
{
|
|
"data": [
|
|
{
|
|
"id": 1,
|
|
"room_name": "Emerald",
|
|
"during": "[\"2000-01-01 13:00:00\",\"2000-01-01 15:00:00\")"
|
|
}
|
|
],
|
|
"status": 200,
|
|
"statusText": "OK"
|
|
}
|
|
```
|
|
|
|
</TabPanel>
|
|
</Tabs>
|
|
hideCodeBlock: true
|
|
- id: on`jsonb`columns
|
|
name: On `jsonb` columns
|
|
description: |
|
|
<Tabs scrollable size="small" type="underlined" defaultActiveId="schema">
|
|
<TabPanel id="schema" label="Schema">
|
|
|
|
```sql
|
|
create table
|
|
users (
|
|
id int8 primary key,
|
|
name text,
|
|
address jsonb
|
|
);
|
|
|
|
insert into
|
|
users (id, name, address)
|
|
values
|
|
(1, 'Michael', '{ "postcode": 90210, "street": "Melrose Place" }'),
|
|
(2, 'Jane', '{}');
|
|
```
|
|
|
|
</TabPanel>
|
|
<TabPanel id="js" label="JavaScript">
|
|
|
|
```ts
|
|
const { data, error } = await supabase
|
|
.from('users')
|
|
.select('name')
|
|
.containedBy('address', {})
|
|
```
|
|
|
|
</TabPanel>
|
|
<TabPanel id="result" label="Result">
|
|
|
|
```json
|
|
{
|
|
"data": [
|
|
{
|
|
"name": "Jane"
|
|
}
|
|
],
|
|
"status": 200,
|
|
"statusText": "OK"
|
|
}
|
|
```
|
|
|
|
</TabPanel>
|
|
</Tabs>
|
|
hideCodeBlock: true
|
|
|
|
- id: rangeGt()
|
|
$ref: '@supabase/postgrest-js.PostgrestFilterBuilder.rangeGt'
|
|
examples:
|
|
- id: with`select()`
|
|
name: With `select()`
|
|
description: |
|
|
Postgres supports a number of [range
|
|
types](https://www.postgresql.org/docs/current/rangetypes.html). You
|
|
can filter on range columns using the string representation of range
|
|
values.
|
|
|
|
<Tabs scrollable size="small" type="underlined" defaultActiveId="schema">
|
|
<TabPanel id="schema" label="Schema">
|
|
|
|
```sql
|
|
create table
|
|
reservations (
|
|
id int8 primary key,
|
|
room_name text,
|
|
during tsrange
|
|
);
|
|
|
|
insert into
|
|
reservations (id, room_name, during)
|
|
values
|
|
(1, 'Emerald', '[2000-01-01 13:00, 2000-01-01 15:00)'),
|
|
(2, 'Topaz', '[2000-01-02 09:00, 2000-01-02 10:00)');
|
|
```
|
|
|
|
</TabPanel>
|
|
<TabPanel id="js" label="JavaScript">
|
|
|
|
```ts
|
|
const { data, error } = await supabase
|
|
.from('reservations')
|
|
.select()
|
|
.rangeGt('during', '[2000-01-02 08:00, 2000-01-02 09:00)')
|
|
```
|
|
|
|
</TabPanel>
|
|
<TabPanel id="result" label="Result">
|
|
|
|
```json
|
|
{
|
|
"data": [
|
|
{
|
|
"id": 2,
|
|
"room_name": "Topaz",
|
|
"during": "[\"2000-01-02 09:00:00\",\"2000-01-02 10:00:00\")"
|
|
}
|
|
],
|
|
"status": 200,
|
|
"statusText": "OK"
|
|
}
|
|
```
|
|
|
|
</TabPanel>
|
|
</Tabs>
|
|
hideCodeBlock: true
|
|
isSpotlight: true
|
|
js: |
|
|
```ts
|
|
const { data, error } = await supabase
|
|
.from('reservations')
|
|
.select()
|
|
.rangeGt('during', '[2000-01-02 08:00, 2000-01-02 09:00)')
|
|
```
|
|
|
|
- id: rangeGte()
|
|
$ref: '@supabase/postgrest-js.PostgrestFilterBuilder.rangeGte'
|
|
examples:
|
|
- id: with`select()`
|
|
name: With `select()`
|
|
description: |
|
|
Postgres supports a number of [range
|
|
types](https://www.postgresql.org/docs/current/rangetypes.html). You
|
|
can filter on range columns using the string representation of range
|
|
values.
|
|
|
|
<Tabs scrollable size="small" type="underlined" defaultActiveId="schema">
|
|
<TabPanel id="schema" label="Schema">
|
|
|
|
```sql
|
|
create table
|
|
reservations (
|
|
id int8 primary key,
|
|
room_name text,
|
|
during tsrange
|
|
);
|
|
|
|
insert into
|
|
reservations (id, room_name, during)
|
|
values
|
|
(1, 'Emerald', '[2000-01-01 13:00, 2000-01-01 15:00)'),
|
|
(2, 'Topaz', '[2000-01-02 09:00, 2000-01-02 10:00)');
|
|
```
|
|
|
|
</TabPanel>
|
|
<TabPanel id="js" label="JavaScript">
|
|
|
|
```ts
|
|
const { data, error } = await supabase
|
|
.from('reservations')
|
|
.select()
|
|
.rangeGte('during', '[2000-01-02 08:30, 2000-01-02 09:30)')
|
|
```
|
|
|
|
</TabPanel>
|
|
<TabPanel id="result" label="Result">
|
|
|
|
```json
|
|
{
|
|
"data": [
|
|
{
|
|
"id": 2,
|
|
"room_name": "Topaz",
|
|
"during": "[\"2000-01-02 09:00:00\",\"2000-01-02 10:00:00\")"
|
|
}
|
|
],
|
|
"status": 200,
|
|
"statusText": "OK"
|
|
}
|
|
```
|
|
|
|
</TabPanel>
|
|
</Tabs>
|
|
hideCodeBlock: true
|
|
isSpotlight: true
|
|
js: |
|
|
```ts
|
|
const { data, error } = await supabase
|
|
.from('reservations')
|
|
.select()
|
|
.rangeGte('during', '[2000-01-02 08:30, 2000-01-02 09:30)')
|
|
```
|
|
|
|
- id: rangeLt()
|
|
$ref: '@supabase/postgrest-js.PostgrestFilterBuilder.rangeLt'
|
|
examples:
|
|
- id: with`select()`
|
|
name: With `select()`
|
|
description: |
|
|
Postgres supports a number of [range
|
|
types](https://www.postgresql.org/docs/current/rangetypes.html). You
|
|
can filter on range columns using the string representation of range
|
|
values.
|
|
|
|
<Tabs scrollable size="small" type="underlined" defaultActiveId="schema">
|
|
<TabPanel id="schema" label="Schema">
|
|
|
|
```sql
|
|
create table
|
|
reservations (
|
|
id int8 primary key,
|
|
room_name text,
|
|
during tsrange
|
|
);
|
|
|
|
insert into
|
|
reservations (id, room_name, during)
|
|
values
|
|
(1, 'Emerald', '[2000-01-01 13:00, 2000-01-01 15:00)'),
|
|
(2, 'Topaz', '[2000-01-02 09:00, 2000-01-02 10:00)');
|
|
```
|
|
|
|
</TabPanel>
|
|
<TabPanel id="js" label="JavaScript">
|
|
|
|
```ts
|
|
const { data, error } = await supabase
|
|
.from('reservations')
|
|
.select()
|
|
.rangeLt('during', '[2000-01-01 15:00, 2000-01-01 16:00)')
|
|
```
|
|
|
|
</TabPanel>
|
|
<TabPanel id="result" label="Result">
|
|
|
|
```json
|
|
{
|
|
"data": [
|
|
{
|
|
"id": 1,
|
|
"room_name": "Emerald",
|
|
"during": "[\"2000-01-01 13:00:00\",\"2000-01-01 15:00:00\")"
|
|
}
|
|
],
|
|
"status": 200,
|
|
"statusText": "OK"
|
|
}
|
|
```
|
|
|
|
</TabPanel>
|
|
</Tabs>
|
|
hideCodeBlock: true
|
|
isSpotlight: true
|
|
js: |
|
|
```ts
|
|
const { data, error } = await supabase
|
|
.from('reservations')
|
|
.select()
|
|
.rangeLt('during', '[2000-01-01 15:00, 2000-01-01 16:00)')
|
|
```
|
|
|
|
- id: rangeLte()
|
|
$ref: '@supabase/postgrest-js.PostgrestFilterBuilder.rangeLte'
|
|
examples:
|
|
- id: with`select()`
|
|
name: With `select()`
|
|
description: |
|
|
Postgres supports a number of [range
|
|
types](https://www.postgresql.org/docs/current/rangetypes.html). You
|
|
can filter on range columns using the string representation of range
|
|
values.
|
|
|
|
<Tabs scrollable size="small" type="underlined" defaultActiveId="schema">
|
|
<TabPanel id="schema" label="Schema">
|
|
|
|
```sql
|
|
create table
|
|
reservations (
|
|
id int8 primary key,
|
|
room_name text,
|
|
during tsrange
|
|
);
|
|
|
|
insert into
|
|
reservations (id, room_name, during)
|
|
values
|
|
(1, 'Emerald', '[2000-01-01 13:00, 2000-01-01 15:00)'),
|
|
(2, 'Topaz', '[2000-01-02 09:00, 2000-01-02 10:00)');
|
|
```
|
|
|
|
</TabPanel>
|
|
<TabPanel id="js" label="JavaScript">
|
|
|
|
```ts
|
|
const { data, error } = await supabase
|
|
.from('reservations')
|
|
.select()
|
|
.rangeLte('during', '[2000-01-01 14:00, 2000-01-01 16:00)')
|
|
```
|
|
|
|
</TabPanel>
|
|
<TabPanel id="result" label="Result">
|
|
|
|
```json
|
|
{
|
|
"data": [
|
|
{
|
|
"id": 1,
|
|
"room_name": "Emerald",
|
|
"during": "[\"2000-01-01 13:00:00\",\"2000-01-01 15:00:00\")"
|
|
}
|
|
],
|
|
"status": 200,
|
|
"statusText": "OK"
|
|
}
|
|
```
|
|
|
|
</TabPanel>
|
|
</Tabs>
|
|
hideCodeBlock: true
|
|
isSpotlight: true
|
|
js: |
|
|
```ts
|
|
const { data, error } = await supabase
|
|
.from('reservations')
|
|
.select()
|
|
.rangeLte('during', '[2000-01-01 14:00, 2000-01-01 16:00)')
|
|
```
|
|
|
|
- id: rangeAdjacent()
|
|
$ref: '@supabase/postgrest-js.PostgrestFilterBuilder.rangeAdjacent'
|
|
examples:
|
|
- id: with`select()`
|
|
name: With `select()`
|
|
description: |
|
|
Postgres supports a number of [range
|
|
types](https://www.postgresql.org/docs/current/rangetypes.html). You
|
|
can filter on range columns using the string representation of range
|
|
values.
|
|
|
|
<Tabs scrollable size="small" type="underlined" defaultActiveId="schema">
|
|
<TabPanel id="schema" label="Schema">
|
|
|
|
```sql
|
|
create table
|
|
reservations (
|
|
id int8 primary key,
|
|
room_name text,
|
|
during tsrange
|
|
);
|
|
|
|
insert into
|
|
reservations (id, room_name, during)
|
|
values
|
|
(1, 'Emerald', '[2000-01-01 13:00, 2000-01-01 15:00)'),
|
|
(2, 'Topaz', '[2000-01-02 09:00, 2000-01-02 10:00)');
|
|
```
|
|
|
|
</TabPanel>
|
|
<TabPanel id="js" label="JavaScript">
|
|
|
|
```ts
|
|
const { data, error } = await supabase
|
|
.from('reservations')
|
|
.select()
|
|
.rangeAdjacent('during', '[2000-01-01 12:00, 2000-01-01 13:00)')
|
|
```
|
|
|
|
</TabPanel>
|
|
<TabPanel id="result" label="Result">
|
|
|
|
```json
|
|
{
|
|
"data": [
|
|
{
|
|
"id": 1,
|
|
"room_name": "Emerald",
|
|
"during": "[\"2000-01-01 13:00:00\",\"2000-01-01 15:00:00\")"
|
|
}
|
|
],
|
|
"status": 200,
|
|
"statusText": "OK"
|
|
}
|
|
```
|
|
|
|
</TabPanel>
|
|
</Tabs>
|
|
hideCodeBlock: true
|
|
isSpotlight: true
|
|
js: |
|
|
```ts
|
|
const { data, error } = await supabase
|
|
.from('reservations')
|
|
.select()
|
|
.rangeAdjacent('during', '[2000-01-01 12:00, 2000-01-01 13:00)')
|
|
```
|
|
|
|
- id: overlaps()
|
|
$ref: '@supabase/postgrest-js.PostgrestFilterBuilder.overlaps'
|
|
examples:
|
|
- id: on-array-columns
|
|
name: On array columns
|
|
description: |
|
|
<Tabs scrollable size="small" type="underlined" defaultActiveId="schema">
|
|
<TabPanel id="schema" label="Schema">
|
|
|
|
```sql
|
|
create table
|
|
issues (
|
|
id int8 primary key,
|
|
title text,
|
|
tags text[]
|
|
);
|
|
|
|
insert into
|
|
issues (id, title, tags)
|
|
values
|
|
(1, 'Cache invalidation is not working', array['is:open', 'severity:high', 'priority:low']),
|
|
(2, 'Use better names', array['is:open', 'severity:low', 'priority:medium']);
|
|
```
|
|
|
|
</TabPanel>
|
|
<TabPanel id="js" label="JavaScript">
|
|
|
|
```ts
|
|
const { data, error } = await supabase
|
|
.from('issues')
|
|
.select('title')
|
|
.overlaps('tags', ['is:closed', 'severity:high'])
|
|
```
|
|
|
|
</TabPanel>
|
|
<TabPanel id="result" label="Result">
|
|
|
|
```json
|
|
{
|
|
"data": [
|
|
{
|
|
"title": "Cache invalidation is not working"
|
|
}
|
|
],
|
|
"status": 200,
|
|
"statusText": "OK"
|
|
}
|
|
```
|
|
|
|
</TabPanel>
|
|
</Tabs>
|
|
hideCodeBlock: true
|
|
isSpotlight: true
|
|
js: |
|
|
```ts
|
|
const { data, error } = await supabase
|
|
.from('issues')
|
|
.select('title')
|
|
.overlaps('tags', ['is:closed', 'severity:high'])
|
|
```
|
|
- id: on-range-columns
|
|
name: On range columns
|
|
description: |
|
|
Postgres supports a number of [range
|
|
types](https://www.postgresql.org/docs/current/rangetypes.html). You
|
|
can filter on range columns using the string representation of range
|
|
values.
|
|
|
|
<Tabs scrollable size="small" type="underlined" defaultActiveId="schema">
|
|
<TabPanel id="schema" label="Schema">
|
|
|
|
```sql
|
|
create table
|
|
reservations (
|
|
id int8 primary key,
|
|
room_name text,
|
|
during tsrange
|
|
);
|
|
|
|
insert into
|
|
reservations (id, room_name, during)
|
|
values
|
|
(1, 'Emerald', '[2000-01-01 13:00, 2000-01-01 15:00)'),
|
|
(2, 'Topaz', '[2000-01-02 09:00, 2000-01-02 10:00)');
|
|
```
|
|
|
|
</TabPanel>
|
|
<TabPanel id="js" label="JavaScript">
|
|
|
|
```ts
|
|
const { data, error } = await supabase
|
|
.from('reservations')
|
|
.select()
|
|
.overlaps('during', '[2000-01-01 12:45, 2000-01-01 13:15)')
|
|
```
|
|
|
|
</TabPanel>
|
|
<TabPanel id="result" label="Result">
|
|
|
|
```json
|
|
{
|
|
"data": [
|
|
{
|
|
"id": 1,
|
|
"room_name": "Emerald",
|
|
"during": "[\"2000-01-01 13:00:00\",\"2000-01-01 15:00:00\")"
|
|
}
|
|
],
|
|
"status": 200,
|
|
"statusText": "OK"
|
|
}
|
|
```
|
|
|
|
</TabPanel>
|
|
</Tabs>
|
|
hideCodeBlock: true
|
|
|
|
# TODO: schema & result
|
|
- id: textSearch()
|
|
$ref: '@supabase/postgrest-js.PostgrestFilterBuilder.textSearch'
|
|
notes:
|
|
- For more information, see [Postgres full text search](/docs/guides/database/full-text-search).
|
|
examples:
|
|
- id: text-search
|
|
name: Text search
|
|
js: |
|
|
```ts
|
|
const { data, error } = await supabase
|
|
.from('quotes')
|
|
.select('catchphrase')
|
|
.textSearch('catchphrase', `'fat' & 'cat'`, {
|
|
config: 'english'
|
|
})
|
|
```
|
|
- id: basic-normalization
|
|
name: Basic normalization
|
|
description: Uses PostgreSQL's `plainto_tsquery` function.
|
|
js: |
|
|
```ts
|
|
const { data, error } = await supabase
|
|
.from('quotes')
|
|
.select('catchphrase')
|
|
.textSearch('catchphrase', `'fat' & 'cat'`, {
|
|
type: 'plain',
|
|
config: 'english'
|
|
})
|
|
```
|
|
- id: full-normalization
|
|
name: Full normalization
|
|
description: Uses PostgreSQL's `phraseto_tsquery` function.
|
|
js: |
|
|
```ts
|
|
const { data, error } = await supabase
|
|
.from('quotes')
|
|
.select('catchphrase')
|
|
.textSearch('catchphrase', `'fat' & 'cat'`, {
|
|
type: 'phrase',
|
|
config: 'english'
|
|
})
|
|
```
|
|
- id: websearch
|
|
name: Websearch
|
|
description: |
|
|
Uses PostgreSQL's `websearch_to_tsquery` function.
|
|
This function will never raise syntax errors, which makes it possible to use raw user-supplied input for search, and can be used
|
|
with advanced operators.
|
|
|
|
- `unquoted text`: text not inside quote marks will be converted to terms separated by & operators, as if processed by plainto_tsquery.
|
|
- `"quoted text"`: text inside quote marks will be converted to terms separated by `<->` operators, as if processed by phraseto_tsquery.
|
|
- `OR`: the word “or” will be converted to the | operator.
|
|
- `-`: a dash will be converted to the ! operator.
|
|
|
|
js: |
|
|
```ts
|
|
const { data, error } = await supabase
|
|
.from('quotes')
|
|
.select('catchphrase')
|
|
.textSearch('catchphrase', `'fat or cat'`, {
|
|
type: 'websearch',
|
|
config: 'english'
|
|
})
|
|
```
|
|
|
|
- id: match()
|
|
$ref: '@supabase/postgrest-js.PostgrestFilterBuilder.match'
|
|
examples:
|
|
- id: with`select()`
|
|
name: With `select()`
|
|
description: |
|
|
<Tabs scrollable size="small" type="underlined" defaultActiveId="schema">
|
|
<TabPanel id="schema" label="Schema">
|
|
|
|
```sql
|
|
create table
|
|
countries (id int8 primary key, name text);
|
|
|
|
insert into
|
|
countries (id, name)
|
|
values
|
|
(1, 'Afghanistan'),
|
|
(2, 'Albania'),
|
|
(3, 'Algeria');
|
|
```
|
|
|
|
</TabPanel>
|
|
<TabPanel id="js" label="JavaScript">
|
|
|
|
```ts
|
|
const { data, error } = await supabase
|
|
.from('countries')
|
|
.select('name')
|
|
.match({ id: 2, name: 'Albania' })
|
|
```
|
|
|
|
</TabPanel>
|
|
<TabPanel id="result" label="Result">
|
|
|
|
```json
|
|
{
|
|
"data": [
|
|
{
|
|
"name": "Albania"
|
|
}
|
|
],
|
|
"status": 200,
|
|
"statusText": "OK"
|
|
}
|
|
```
|
|
|
|
</TabPanel>
|
|
</Tabs>
|
|
hideCodeBlock: true
|
|
isSpotlight: true
|
|
js: |
|
|
```ts
|
|
const { data, error } = await supabase
|
|
.from('countries')
|
|
.select('name')
|
|
.match({ id: 2, name: 'Albania' })
|
|
```
|
|
|
|
- id: not()
|
|
$ref: '@supabase/postgrest-js.PostgrestFilterBuilder.not'
|
|
notes: |
|
|
not() expects you to use the raw PostgREST syntax for the filter values.
|
|
|
|
```ts
|
|
.not('id', 'in', '(5,6,7)') // Use `()` for `in` filter
|
|
.not('arraycol', 'cs', '{"a","b"}') // Use `cs` for `contains()`, `{}` for array values
|
|
```
|
|
examples:
|
|
- id: with`select()`
|
|
name: With `select()`
|
|
description: |
|
|
<Tabs scrollable size="small" type="underlined" defaultActiveId="schema">
|
|
<TabPanel id="schema" label="Schema">
|
|
|
|
```sql
|
|
create table
|
|
countries (id int8 primary key, name text);
|
|
|
|
insert into
|
|
countries (id, name)
|
|
values
|
|
(1, 'null'),
|
|
(2, null);
|
|
```
|
|
|
|
</TabPanel>
|
|
<TabPanel id="js" label="JavaScript">
|
|
|
|
```ts
|
|
const { data, error } = await supabase
|
|
.from('countries')
|
|
.select()
|
|
.not('name', 'is', null)
|
|
```
|
|
|
|
</TabPanel>
|
|
<TabPanel id="result" label="Result">
|
|
|
|
```json
|
|
{
|
|
"data": [
|
|
{
|
|
"id": 1,
|
|
"name": "null"
|
|
}
|
|
],
|
|
"status": 200,
|
|
"statusText": "OK"
|
|
}
|
|
```
|
|
|
|
</TabPanel>
|
|
</Tabs>
|
|
hideCodeBlock: true
|
|
isSpotlight: true
|
|
js: |
|
|
```ts
|
|
const { data, error } = await supabase
|
|
.from('countries')
|
|
.select()
|
|
.not('name', 'is', null)
|
|
```
|
|
|
|
- id: or()
|
|
$ref: '@supabase/postgrest-js.PostgrestFilterBuilder.or'
|
|
notes: |
|
|
or() expects you to use the raw PostgREST syntax for the filter names and values.
|
|
|
|
```ts
|
|
.or('id.in.(5,6,7), arraycol.cs.{"a","b"}') // Use `()` for `in` filter, `{}` for array values and `cs` for `contains()`.
|
|
.or('id.in.(5,6,7), arraycol.cd.{"a","b"}') // Use `cd` for `containedBy()`
|
|
```
|
|
examples:
|
|
- id: with`select()`
|
|
name: With `select()`
|
|
description: |
|
|
<Tabs scrollable size="small" type="underlined" defaultActiveId="schema">
|
|
<TabPanel id="schema" label="Schema">
|
|
|
|
```sql
|
|
create table
|
|
countries (id int8 primary key, name text);
|
|
|
|
insert into
|
|
countries (id, name)
|
|
values
|
|
(1, 'Afghanistan'),
|
|
(2, 'Albania'),
|
|
(3, 'Algeria');
|
|
```
|
|
|
|
</TabPanel>
|
|
<TabPanel id="js" label="JavaScript">
|
|
|
|
```ts
|
|
const { data, error } = await supabase
|
|
.from('countries')
|
|
.select('name')
|
|
.or('id.eq.2,name.eq.Algeria')
|
|
```
|
|
|
|
</TabPanel>
|
|
<TabPanel id="result" label="Result">
|
|
|
|
```json
|
|
{
|
|
"data": [
|
|
{
|
|
"name": "Albania"
|
|
},
|
|
{
|
|
"name": "Algeria"
|
|
}
|
|
],
|
|
"status": 200,
|
|
"statusText": "OK"
|
|
}
|
|
```
|
|
|
|
</TabPanel>
|
|
</Tabs>
|
|
hideCodeBlock: true
|
|
isSpotlight: true
|
|
js: |
|
|
```ts
|
|
const { data, error } = await supabase
|
|
.from('countries')
|
|
.select('name')
|
|
.or('id.eq.2,name.eq.Algeria')
|
|
```
|
|
- id: use`or`with`and`
|
|
name: Use `or` with `and`
|
|
description: |
|
|
<Tabs scrollable size="small" type="underlined" defaultActiveId="schema">
|
|
<TabPanel id="schema" label="Schema">
|
|
|
|
```sql
|
|
create table
|
|
countries (id int8 primary key, name text);
|
|
|
|
insert into
|
|
countries (id, name)
|
|
values
|
|
(1, 'Afghanistan'),
|
|
(2, 'Albania'),
|
|
(3, 'Algeria');
|
|
```
|
|
|
|
</TabPanel>
|
|
<TabPanel id="js" label="JavaScript">
|
|
|
|
```ts
|
|
const { data, error } = await supabase
|
|
.from('countries')
|
|
.select('name')
|
|
.or('id.gt.3,and(id.eq.1,name.eq.Afghanistan)')
|
|
```
|
|
|
|
</TabPanel>
|
|
<TabPanel id="result" label="Result">
|
|
|
|
|
|
```json
|
|
{
|
|
"data": [
|
|
{
|
|
"name": "Afghanistan"
|
|
}
|
|
],
|
|
"status": 200,
|
|
"statusText": "OK"
|
|
}
|
|
```
|
|
|
|
</TabPanel>
|
|
</Tabs>
|
|
hideCodeBlock: true
|
|
- id: use`or`on-foreign-tables
|
|
name: Use `or` on referenced tables
|
|
description: |
|
|
<Tabs scrollable size="small" type="underlined" defaultActiveId="schema">
|
|
<TabPanel id="schema" label="Schema">
|
|
|
|
```sql
|
|
create table
|
|
countries (id int8 primary key, name text);
|
|
create table
|
|
cities (
|
|
id int8 primary key,
|
|
country_id int8 not null references countries,
|
|
name text
|
|
);
|
|
|
|
insert into
|
|
countries (id, name)
|
|
values
|
|
(1, 'Germany'),
|
|
(2, 'Indonesia');
|
|
insert into
|
|
cities (id, country_id, name)
|
|
values
|
|
(1, 2, 'Bali'),
|
|
(2, 1, 'Munich');
|
|
```
|
|
|
|
</TabPanel>
|
|
<TabPanel id="js" label="JavaScript">
|
|
|
|
```ts
|
|
const { data, error } = await supabase
|
|
.from('countries')
|
|
.select(`
|
|
name,
|
|
cities!inner (
|
|
name
|
|
)
|
|
`)
|
|
.or('country_id.eq.1,name.eq.Beijing', { foreignTable: 'cities' })
|
|
```
|
|
|
|
</TabPanel>
|
|
<TabPanel id="result" label="Result">
|
|
|
|
```json
|
|
{
|
|
"data": [
|
|
{
|
|
"name": "Germany",
|
|
"cities": [
|
|
{
|
|
"name": "Munich"
|
|
}
|
|
]
|
|
}
|
|
],
|
|
"status": 200,
|
|
"statusText": "OK"
|
|
}
|
|
```
|
|
|
|
</TabPanel>
|
|
</Tabs>
|
|
hideCodeBlock: true
|
|
|
|
- id: filter()
|
|
$ref: '@supabase/postgrest-js.PostgrestFilterBuilder.filter'
|
|
notes: |
|
|
filter() expects you to use the raw PostgREST syntax for the filter values.
|
|
|
|
```ts
|
|
.filter('id', 'in', '(5,6,7)') // Use `()` for `in` filter
|
|
.filter('arraycol', 'cs', '{"a","b"}') // Use `cs` for `contains()`, `{}` for array values
|
|
```
|
|
examples:
|
|
- id: with`select()`
|
|
name: With `select()`
|
|
description: |
|
|
<Tabs scrollable size="small" type="underlined" defaultActiveId="schema">
|
|
<TabPanel id="schema" label="Schema">
|
|
|
|
```sql
|
|
create table
|
|
countries (id int8 primary key, name text);
|
|
|
|
insert into
|
|
countries (id, name)
|
|
values
|
|
(1, 'Afghanistan'),
|
|
(2, 'Albania'),
|
|
(3, 'Algeria');
|
|
```
|
|
|
|
</TabPanel>
|
|
<TabPanel id="js" label="JavaScript">
|
|
|
|
```ts
|
|
const { data, error } = await supabase
|
|
.from('countries')
|
|
.select()
|
|
.filter('name', 'in', '("Algeria","Japan")')
|
|
```
|
|
|
|
</TabPanel>
|
|
<TabPanel id="result" label="Result">
|
|
|
|
```json
|
|
{
|
|
"data": [
|
|
{
|
|
"id": 3,
|
|
"name": "Algeria"
|
|
}
|
|
],
|
|
"status": 200,
|
|
"statusText": "OK"
|
|
}
|
|
```
|
|
|
|
</TabPanel>
|
|
</Tabs>
|
|
hideCodeBlock: true
|
|
isSpotlight: true
|
|
js: |
|
|
```ts
|
|
const { data, error } = await supabase
|
|
.from('countries')
|
|
.select()
|
|
.filter('name', 'in', '("Algeria","Japan")')
|
|
```
|
|
- id: on-a-foreign-table
|
|
name: On a referenced table
|
|
description: |
|
|
<Tabs scrollable size="small" type="underlined" defaultActiveId="schema">
|
|
<TabPanel id="schema" label="Schema">
|
|
|
|
```sql
|
|
create table
|
|
countries (id int8 primary key, name text);
|
|
create table
|
|
cities (
|
|
id int8 primary key,
|
|
country_id int8 not null references countries,
|
|
name text
|
|
);
|
|
|
|
insert into
|
|
countries (id, name)
|
|
values
|
|
(1, 'Germany'),
|
|
(2, 'Indonesia');
|
|
insert into
|
|
cities (id, country_id, name)
|
|
values
|
|
(1, 2, 'Bali'),
|
|
(2, 1, 'Munich');
|
|
```
|
|
|
|
</TabPanel>
|
|
<TabPanel id="js" label="JavaScript">
|
|
|
|
```ts
|
|
const { data, error } = await supabase
|
|
.from('countries')
|
|
.select(`
|
|
name,
|
|
cities!inner (
|
|
name
|
|
)
|
|
`)
|
|
.filter('cities.name', 'eq', 'Bali')
|
|
```
|
|
|
|
</TabPanel>
|
|
<TabPanel id="result" label="Result">
|
|
|
|
```json
|
|
{
|
|
"data": [
|
|
{
|
|
"name": "Indonesia",
|
|
"cities": [
|
|
{
|
|
"name": "Bali"
|
|
}
|
|
]
|
|
}
|
|
],
|
|
"status": 200,
|
|
"statusText": "OK"
|
|
}
|
|
```
|
|
|
|
</TabPanel>
|
|
</Tabs>
|
|
hideCodeBlock: true
|
|
js: |
|
|
```ts
|
|
const { data, error } = await supabase
|
|
.from('countries')
|
|
.select(`
|
|
name,
|
|
cities!inner (
|
|
name
|
|
)
|
|
`)
|
|
.filter('cities.name', 'eq', 'Bali')
|
|
```
|
|
|
|
- id: Using Modifiers
|
|
description: |
|
|
Filters work on the row level—they allow you to return rows that
|
|
only match certain conditions without changing the shape of the rows.
|
|
Modifiers are everything that don't fit that definition—allowing you to
|
|
change the format of the response (e.g., returning a CSV string).
|
|
|
|
Modifiers must be specified after filters. Some modifiers only apply for
|
|
queries that return rows (e.g., `select()` or `rpc()` on a function that
|
|
returns a table response).
|
|
|
|
- id: db.modifiers.select()
|
|
$ref: '@supabase/postgrest-js.PostgrestTransformBuilder.select'
|
|
title: select()
|
|
examples:
|
|
- id: with`upsert()`
|
|
name: With `upsert()`
|
|
description: |
|
|
<Tabs scrollable size="small" type="underlined" defaultActiveId="schema">
|
|
<TabPanel id="schema" label="Schema">
|
|
|
|
```sql
|
|
create table
|
|
countries (id int8 primary key, name text);
|
|
|
|
insert into
|
|
countries (id, name)
|
|
values
|
|
(1, 'Afghanistan');
|
|
```
|
|
|
|
</TabPanel>
|
|
<TabPanel id="js" label="JavaScript">
|
|
|
|
```ts
|
|
const { data, error } = await supabase
|
|
.from('countries')
|
|
.upsert({ id: 1, name: 'Albania' })
|
|
```
|
|
|
|
</TabPanel>
|
|
<TabPanel id="result" label="Result">
|
|
|
|
```json
|
|
{
|
|
"status": 201,
|
|
"statusText": "Created"
|
|
}
|
|
```
|
|
|
|
</TabPanel>
|
|
</Tabs>
|
|
|
|
<Tabs scrollable size="small" type="underlined" defaultActiveId="js">
|
|
<TabPanel id="js" label="JavaScript">
|
|
|
|
```ts
|
|
const { data, error } = await supabase
|
|
.from('countries')
|
|
.upsert({ id: 1, name: 'Algeria' })
|
|
.select()
|
|
```
|
|
|
|
</TabPanel>
|
|
<TabPanel id="result" label="Result">
|
|
|
|
```json
|
|
{
|
|
"data": [
|
|
{
|
|
"id": 1,
|
|
"name": "Algeria"
|
|
}
|
|
],
|
|
"status": 201,
|
|
"statusText": "Created"
|
|
}
|
|
```
|
|
|
|
</TabPanel>
|
|
</Tabs>
|
|
hideCodeBlock: true
|
|
isSpotlight: true
|
|
js: |
|
|
```ts
|
|
const { data, error } = await supabase
|
|
.from('countries')
|
|
.upsert({ id: 1, name: 'Algeria' })
|
|
.select()
|
|
```
|
|
|
|
- id: order()
|
|
$ref: '@supabase/postgrest-js.PostgrestTransformBuilder.order'
|
|
examples:
|
|
- id: with`select()`
|
|
name: With `select()`
|
|
description: |
|
|
<Tabs scrollable size="small" type="underlined" defaultActiveId="schema">
|
|
<TabPanel id="schema" label="Schema">
|
|
|
|
```sql
|
|
create table
|
|
countries (id int8 primary key, name text);
|
|
|
|
insert into
|
|
countries (id, name)
|
|
values
|
|
(1, 'Afghanistan'),
|
|
(2, 'Albania'),
|
|
(3, 'Algeria');
|
|
```
|
|
|
|
</TabPanel>
|
|
<TabPanel id="js" label="JavaScript">
|
|
|
|
```ts
|
|
const { data, error } = await supabase
|
|
.from('countries')
|
|
.select()
|
|
.order('name', { ascending: false })
|
|
```
|
|
|
|
</TabPanel>
|
|
<TabPanel id="result" label="Result">
|
|
|
|
```json
|
|
{
|
|
"data": [
|
|
{
|
|
"id": 3,
|
|
"name": "Algeria"
|
|
},
|
|
{
|
|
"id": 2,
|
|
"name": "Albania"
|
|
},
|
|
{
|
|
"id": 1,
|
|
"name": "Afghanistan"
|
|
}
|
|
],
|
|
"status": 200,
|
|
"statusText": "OK"
|
|
}
|
|
```
|
|
|
|
</TabPanel>
|
|
</Tabs>
|
|
hideCodeBlock: true
|
|
isSpotlight: true
|
|
js: |
|
|
```ts
|
|
const { data, error } = await supabase
|
|
.from('cities')
|
|
.select('name', 'country_id')
|
|
.order('id', { ascending: false })
|
|
```
|
|
- id: on-a-foreign-table
|
|
name: On a referenced table
|
|
description: |
|
|
Ordering on referenced tables doesn't affect the ordering of
|
|
the parent table.
|
|
|
|
<Tabs scrollable size="small" type="underlined" defaultActiveId="schema">
|
|
<TabPanel id="schema" label="Schema">
|
|
|
|
```sql
|
|
create table
|
|
countries (id int8 primary key, name text);
|
|
create table
|
|
cities (
|
|
id int8 primary key,
|
|
country_id int8 not null references countries,
|
|
name text
|
|
);
|
|
|
|
insert into
|
|
countries (id, name)
|
|
values
|
|
(1, 'United States'),
|
|
(2, 'Vanuatu');
|
|
insert into
|
|
cities (id, country_id, name)
|
|
values
|
|
(1, 1, 'Atlanta'),
|
|
(2, 1, 'New York City');
|
|
```
|
|
|
|
</TabPanel>
|
|
<TabPanel id="js" label="JavaScript">
|
|
|
|
```ts
|
|
const { data, error } = await supabase
|
|
.from('countries')
|
|
.select(`
|
|
name,
|
|
cities (
|
|
name
|
|
)
|
|
`)
|
|
.order('name', { foreignTable: 'cities', ascending: false })
|
|
```
|
|
|
|
</TabPanel>
|
|
<TabPanel id="result" label="Result">
|
|
|
|
```json
|
|
{
|
|
"data": [
|
|
{
|
|
"name": "United States",
|
|
"cities": [
|
|
{
|
|
"name": "New York City"
|
|
},
|
|
{
|
|
"name": "Atlanta"
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"name": "Vanuatu",
|
|
"cities": []
|
|
}
|
|
],
|
|
"status": 200,
|
|
"statusText": "OK"
|
|
}
|
|
```
|
|
|
|
</TabPanel>
|
|
</Tabs>
|
|
hideCodeBlock: true
|
|
- id: order-parent-table-by-a-referenced-table
|
|
name: Order parent table by a referenced table
|
|
code: |
|
|
```ts
|
|
const { data, error } = await supabase
|
|
.from('cities')
|
|
.select(`
|
|
name,
|
|
country:countries (
|
|
name
|
|
)
|
|
`)
|
|
.order('country(name)', { ascending: true })
|
|
```
|
|
data:
|
|
sql: |
|
|
```sql
|
|
create table
|
|
countries (id int8 primary key, name text);
|
|
create table
|
|
cities (
|
|
id int8 primary key,
|
|
country_id int8 not null references countries,
|
|
name text
|
|
);
|
|
|
|
insert into
|
|
countries (id, name)
|
|
values
|
|
(1, 'Germany'),
|
|
(2, 'Indonesia');
|
|
insert into
|
|
cities (id, country_id, name)
|
|
values
|
|
(1, 1, 'Munich'),
|
|
(2, 1, 'Bali');
|
|
```
|
|
response: |
|
|
```json
|
|
{
|
|
"data": [
|
|
{
|
|
"name": "Munich",
|
|
"country": { "name": "Germany" }
|
|
},
|
|
{
|
|
"name": "Bali",
|
|
"country": { "name": "Indonesia" }
|
|
}
|
|
],
|
|
"status": 200,
|
|
"statusText": "OK"
|
|
}
|
|
```
|
|
description: |
|
|
Ordering with `referenced_table(col)` affects the ordering of the
|
|
parent table.
|
|
hideCodeBlock: true
|
|
|
|
- id: limit()
|
|
$ref: '@supabase/postgrest-js.PostgrestTransformBuilder.limit'
|
|
examples:
|
|
- id: with`select()`
|
|
name: With `select()`
|
|
description: |
|
|
<Tabs scrollable size="small" type="underlined" defaultActiveId="schema">
|
|
<TabPanel id="schema" label="Schema">
|
|
|
|
```sql
|
|
create table
|
|
countries (id int8 primary key, name text);
|
|
|
|
insert into
|
|
countries (id, name)
|
|
values
|
|
(1, 'Afghanistan'),
|
|
(2, 'Albania'),
|
|
(3, 'Algeria');
|
|
```
|
|
|
|
</TabPanel>
|
|
<TabPanel id="js" label="JavaScript">
|
|
|
|
```ts
|
|
const { data, error } = await supabase
|
|
.from('countries')
|
|
.select('name')
|
|
.limit(1)
|
|
```
|
|
|
|
</TabPanel>
|
|
<TabPanel id="result" label="Result">
|
|
|
|
```json
|
|
{
|
|
"data": [
|
|
{
|
|
"name": "Afghanistan"
|
|
}
|
|
],
|
|
"status": 200,
|
|
"statusText": "OK"
|
|
}
|
|
```
|
|
|
|
</TabPanel>
|
|
</Tabs>
|
|
hideCodeBlock: true
|
|
isSpotlight: true
|
|
js: |
|
|
```ts
|
|
const { data, error } = await supabase
|
|
.from('countries')
|
|
.select('name')
|
|
.limit(1)
|
|
```
|
|
- id: on-a-foreign-table
|
|
name: On a referenced table
|
|
description: |
|
|
<Tabs scrollable size="small" type="underlined" defaultActiveId="schema">
|
|
<TabPanel id="schema" label="Schema">
|
|
|
|
```sql
|
|
create table
|
|
countries (id int8 primary key, name text);
|
|
create table
|
|
cities (
|
|
id int8 primary key,
|
|
country_id int8 not null references countries,
|
|
name text
|
|
);
|
|
|
|
insert into
|
|
countries (id, name)
|
|
values
|
|
(1, 'United States');
|
|
insert into
|
|
cities (id, country_id, name)
|
|
values
|
|
(1, 1, 'Atlanta'),
|
|
(2, 1, 'New York City');
|
|
```
|
|
|
|
</TabPanel>
|
|
<TabPanel id="js" label="JavaScript">
|
|
|
|
```ts
|
|
const { data, error } = await supabase
|
|
.from('countries')
|
|
.select(`
|
|
name,
|
|
cities (
|
|
name
|
|
)
|
|
`)
|
|
.limit(1, { foreignTable: 'cities' })
|
|
```
|
|
|
|
</TabPanel>
|
|
<TabPanel id="result" label="Result">
|
|
|
|
```json
|
|
{
|
|
"data": [
|
|
{
|
|
"name": "United States",
|
|
"cities": [
|
|
{
|
|
"name": "Atlanta"
|
|
}
|
|
]
|
|
}
|
|
],
|
|
"status": 200,
|
|
"statusText": "OK"
|
|
}
|
|
```
|
|
|
|
</TabPanel>
|
|
</Tabs>
|
|
hideCodeBlock: true
|
|
|
|
- id: range()
|
|
$ref: '@supabase/postgrest-js.PostgrestTransformBuilder.range'
|
|
examples:
|
|
- id: with`select()`
|
|
name: With `select()`
|
|
description: |
|
|
<Tabs scrollable size="small" type="underlined" defaultActiveId="schema">
|
|
<TabPanel id="schema" label="Schema">
|
|
|
|
```sql
|
|
create table
|
|
countries (id int8 primary key, name text);
|
|
|
|
insert into
|
|
countries (id, name)
|
|
values
|
|
(1, 'Afghanistan'),
|
|
(2, 'Albania'),
|
|
(3, 'Algeria');
|
|
```
|
|
|
|
</TabPanel>
|
|
<TabPanel id="js" label="JavaScript">
|
|
|
|
```ts
|
|
const { data, error } = await supabase
|
|
.from('countries')
|
|
.select('name')
|
|
.range(0, 1)
|
|
```
|
|
|
|
</TabPanel>
|
|
<TabPanel id="result" label="Result">
|
|
|
|
```json
|
|
{
|
|
"data": [
|
|
{
|
|
"name": "Afghanistan"
|
|
},
|
|
{
|
|
"name": "Albania"
|
|
}
|
|
],
|
|
"status": 200,
|
|
"statusText": "OK"
|
|
}
|
|
```
|
|
|
|
</TabPanel>
|
|
</Tabs>
|
|
hideCodeBlock: true
|
|
isSpotlight: true
|
|
js: |
|
|
```ts
|
|
const { data, error } = await supabase
|
|
.from('countries')
|
|
.select('name')
|
|
.range(0, 1)
|
|
```
|
|
|
|
- id: db.abortSignal()
|
|
$ref: '@supabase/postgrest-js.PostgrestTransformBuilder.abortSignal'
|
|
title: abortSignal()
|
|
examples:
|
|
- id: aborting-requests-in-flight
|
|
name: Aborting requests in-flight
|
|
description: |
|
|
You can use an [`AbortController`](https://developer.mozilla.org/en-US/docs/Web/API/AbortController) to abort requests. Note that `status` and `statusText` don't mean anything for aborted requests as the request wasn't fulfilled.
|
|
|
|
<Tabs scrollable size="small" type="underlined" defaultActiveId="js">
|
|
<TabPanel id="js" label="JavaScript">
|
|
|
|
```ts
|
|
const ac = new AbortController()
|
|
ac.abort()
|
|
const { data, error } = await supabase
|
|
.from('very_big_table')
|
|
.select()
|
|
.abortSignal(ac.signal)
|
|
```
|
|
|
|
</TabPanel>
|
|
<TabPanel id="result" label="Result">
|
|
|
|
```json
|
|
{
|
|
"error": {
|
|
"message": "FetchError: The user aborted a request.",
|
|
"details": "",
|
|
"hint": "",
|
|
"code": ""
|
|
},
|
|
"status": 400,
|
|
"statusText": "Bad Request"
|
|
}
|
|
```
|
|
|
|
</TabPanel>
|
|
</Tabs>
|
|
hideCodeBlock: true
|
|
isSpotlight: true
|
|
js: |
|
|
```ts
|
|
const ac = new AbortController()
|
|
ac.abort()
|
|
const { data, error } = await supabase
|
|
.from('very_big_table')
|
|
.select()
|
|
.abortSignal(ac.signal)
|
|
```
|
|
|
|
- id: single()
|
|
$ref: '@supabase/postgrest-js.PostgrestTransformBuilder.single'
|
|
examples:
|
|
- id: with`select()`
|
|
name: With `select()`
|
|
description: |
|
|
<Tabs scrollable size="small" type="underlined" defaultActiveId="schema">
|
|
<TabPanel id="schema" label="Schema">
|
|
|
|
```sql
|
|
create table
|
|
countries (id int8 primary key, name text);
|
|
|
|
insert into
|
|
countries (id, name)
|
|
values
|
|
(1, 'Afghanistan'),
|
|
(2, 'Albania'),
|
|
(3, 'Algeria');
|
|
```
|
|
|
|
</TabPanel>
|
|
<TabPanel id="js" label="JavaScript">
|
|
|
|
```ts
|
|
const { data, error } = await supabase
|
|
.from('countries')
|
|
.select('name')
|
|
.limit(1)
|
|
.single()
|
|
```
|
|
|
|
</TabPanel>
|
|
<TabPanel id="result" label="Result">
|
|
|
|
```json
|
|
{
|
|
"data": {
|
|
"name": "Afghanistan"
|
|
},
|
|
"status": 200,
|
|
"statusText": "OK"
|
|
}
|
|
```
|
|
|
|
</TabPanel>
|
|
</Tabs>
|
|
hideCodeBlock: true
|
|
isSpotlight: true
|
|
js: |
|
|
```ts
|
|
const { data, error } = await supabase
|
|
.from('countries')
|
|
.select('name')
|
|
.limit(1)
|
|
.single()
|
|
```
|
|
|
|
- id: maybeSingle()
|
|
$ref: '@supabase/postgrest-js.PostgrestTransformBuilder.maybeSingle'
|
|
examples:
|
|
- id: with`select()`
|
|
name: With `select()`
|
|
description: |
|
|
<Tabs scrollable size="small" type="underlined" defaultActiveId="schema">
|
|
<TabPanel id="schema" label="Schema">
|
|
|
|
```sql
|
|
create table
|
|
countries (id int8 primary key, name text);
|
|
|
|
insert into
|
|
countries (id, name)
|
|
values
|
|
(1, 'Afghanistan'),
|
|
(2, 'Albania'),
|
|
(3, 'Algeria');
|
|
```
|
|
|
|
</TabPanel>
|
|
<TabPanel id="js" label="JavaScript">
|
|
|
|
```ts
|
|
const { data, error } = await supabase
|
|
.from('countries')
|
|
.select()
|
|
.eq('name', 'Singapore')
|
|
.maybeSingle()
|
|
```
|
|
|
|
</TabPanel>
|
|
<TabPanel id="result" label="Result">
|
|
|
|
```json
|
|
{
|
|
"status": 200,
|
|
"statusText": "OK"
|
|
}
|
|
```
|
|
|
|
</TabPanel>
|
|
</Tabs>
|
|
hideCodeBlock: true
|
|
isSpotlight: true
|
|
js: |
|
|
```ts
|
|
const { data, error } = await supabase
|
|
.from('countries')
|
|
.select()
|
|
.eq('name', 'Singapore')
|
|
.maybeSingle()
|
|
```
|
|
|
|
- id: db.csv()
|
|
$ref: '@supabase/postgrest-js.PostgrestTransformBuilder.csv'
|
|
title: csv()
|
|
examples:
|
|
- id: return-data-as-csv
|
|
name: Return data as CSV
|
|
description: |
|
|
By default, the data is returned in JSON format, but can also be returned as Comma Separated Values.
|
|
|
|
<Tabs scrollable size="small" type="underlined" defaultActiveId="schema">
|
|
<TabPanel id="schema" label="Schema">
|
|
|
|
```sql
|
|
create table
|
|
countries (id int8 primary key, name text);
|
|
|
|
insert into
|
|
countries (id, name)
|
|
values
|
|
(1, 'Afghanistan'),
|
|
(2, 'Albania'),
|
|
(3, 'Algeria');
|
|
```
|
|
|
|
</TabPanel>
|
|
<TabPanel id="js" label="JavaScript">
|
|
|
|
```ts
|
|
const { data, error } = await supabase
|
|
.from('countries')
|
|
.select()
|
|
.csv()
|
|
```
|
|
|
|
</TabPanel>
|
|
<TabPanel id="result" label="Result">
|
|
|
|
```json
|
|
{
|
|
"data": "id,name\n1,Afghanistan\n2,Albania\n3,Algeria",
|
|
"status": 200,
|
|
"statusText": "OK"
|
|
}
|
|
```
|
|
|
|
</TabPanel>
|
|
</Tabs>
|
|
hideCodeBlock: true
|
|
isSpotlight: true
|
|
js: |
|
|
```ts
|
|
const { data, error } = await supabase
|
|
.from('countries')
|
|
.select()
|
|
.csv()
|
|
```
|
|
|
|
# NOTE: Not available on currently deployed PostgREST
|
|
# db.geojson():
|
|
# $ref: '@supabase/postgrest-js.PostgrestTransformBuilder.geojson'
|
|
# title: geojson()
|
|
|
|
# NOTE: Not available on currently deployed PostgREST
|
|
# db.explain():
|
|
# $ref: '@supabase/postgrest-js.PostgrestTransformBuilder.explain'
|
|
# title: explain()
|
|
|
|
# NOTE: Not available on currently deployed PostgREST
|
|
# db.rollback():
|
|
# $ref: '@supabase/postgrest-js.PostgrestTransformBuilder.rollback'
|
|
# title: rollback()
|
|
# examples:
|
|
# - id: With `delete()`
|
|
# description: |
|
|
# <details>
|
|
# <summary>Schema</summary>
|
|
|
|
# ```sql
|
|
# create table
|
|
# countries (id int8 primary key, name text);
|
|
|
|
# insert into
|
|
# countries (id, name)
|
|
# values
|
|
# (1, 'Spain');
|
|
# ```
|
|
# </details>
|
|
|
|
# ```ts
|
|
# const { error } = await supabase
|
|
# .from('countries')
|
|
# .delete()
|
|
# .eq('id', 1)
|
|
# .rollback()
|
|
# ```
|
|
|
|
# <details>
|
|
# <summary>Result</summary>
|
|
|
|
# ```json
|
|
# {
|
|
# "status": 204,
|
|
# "statusText": "No Content"
|
|
# }
|
|
# ```
|
|
# </details>
|
|
|
|
# ```ts
|
|
# const { data, error } = await supabase
|
|
# .from('countries')
|
|
# .select()
|
|
# ```
|
|
|
|
# <details>
|
|
# <summary>Result</summary>
|
|
|
|
# ```json
|
|
# {
|
|
# "data": [
|
|
# {
|
|
# "id": 1,
|
|
# "name": "Spain"
|
|
# }
|
|
# ],
|
|
# "status": 200,
|
|
# "statusText": "OK"
|
|
# }
|
|
# ```
|
|
# </details>
|
|
# hideCodeBlock: true
|
|
# isSpotlight: true
|
|
# js: |
|
|
# ```ts
|
|
# const { error } = await supabase
|
|
# .from('countries')
|
|
# .delete()
|
|
# .eq('id', 1)
|
|
# ```
|
|
|
|
- id: invoke()
|
|
title: 'invoke()'
|
|
description: |
|
|
Invoke a Supabase Function.
|
|
$ref: '@supabase/functions-js.FunctionsClient.invoke'
|
|
notes: |
|
|
- Requires an Authorization header.
|
|
- Invoke params generally match the [Fetch API](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API) spec.
|
|
- When you pass in a body to your function, we automatically attach the Content-Type header for `Blob`, `ArrayBuffer`, `File`, `FormData` and `String`. If it doesn't match any of these types we assume the payload is `json`, serialise it and attach the `Content-Type` header as `application/json`. You can override this behaviour by passing in a `Content-Type` header of your own.
|
|
- Responses are automatically parsed as `json`, `blob` and `form-data` depending on the `Content-Type` header sent by your function. Responses are parsed as `text` by default.
|
|
examples:
|
|
- id: basic-invocation.
|
|
name: Basic invocation.
|
|
description:
|
|
isSpotlight: true
|
|
js: |
|
|
```js
|
|
const { data, error } = await supabase.functions.invoke('hello', {
|
|
body: { foo: 'bar' }
|
|
})
|
|
```
|
|
- id: error-handling.
|
|
name: Error handling.
|
|
description: |
|
|
A `FunctionsHttpError` error is returned if your function throws an error, `FunctionsRelayError` if the Supabase Relay has an error processing your function and `FunctionsFetchError` if there is a network error in calling your function.
|
|
isSpotlight: true
|
|
js: |
|
|
```js
|
|
import { FunctionsHttpError, FunctionsRelayError, FunctionsFetchError } from "@supabase/supabase-js";
|
|
|
|
const { data, error } = await supabase.functions.invoke('hello', {
|
|
headers: {
|
|
"my-custom-header": 'my-custom-header-value'
|
|
},
|
|
body: { foo: 'bar' }
|
|
})
|
|
|
|
if (error instanceof FunctionsHttpError) {
|
|
const errorMessage = await error.context.json()
|
|
console.log('Function returned an error', errorMessage)
|
|
} else if (error instanceof FunctionsRelayError) {
|
|
console.log('Relay error:', error.message)
|
|
} else if (error instanceof FunctionsFetchError) {
|
|
console.log('Fetch error:', error.message)
|
|
}
|
|
```
|
|
- id: passing-custom-headers.
|
|
name: Passing custom headers.
|
|
description: |
|
|
You can pass custom headers to your function. Note: supabase-js automatically passes the `Authorization` header with the signed in user's JWT.
|
|
isSpotlight: true
|
|
js: |
|
|
```js
|
|
const { data, error } = await supabase.functions.invoke('hello', {
|
|
headers: {
|
|
"my-custom-header": 'my-custom-header-value'
|
|
},
|
|
body: { foo: 'bar' }
|
|
})
|
|
```
|
|
|
|
- id: subscribe()
|
|
title: 'on().subscribe()'
|
|
$ref: '@supabase/realtime-js.RealtimeChannel.on'
|
|
notes: |
|
|
- Realtime is disabled by default for new Projects for better database performance and security. You can turn it on by [managing replication](/docs/guides/database/api#managing-realtime).
|
|
- Row level security is not applied to delete statements.
|
|
- If you want to receive the "previous" data for updates and deletes, you will need to set `REPLICA IDENTITY` to `FULL`, like this: `ALTER TABLE your_table REPLICA IDENTITY FULL;`
|
|
- When a delete occurs, the contents of old_record will be broadcast to all subscribers to that table so ensure that each table's replica identity only contains information that is safe to expose publicly.
|
|
- The channel name must exactly match the schema/table/filter you want to listen to separated by colons. See below examples for additional context.
|
|
examples:
|
|
- id: listen-to-all-database-changes
|
|
name: Listen to all database changes
|
|
isSpotlight: true
|
|
js: |
|
|
```js
|
|
supabase
|
|
.channel('*')
|
|
.on('postgres_changes', { event: '*', schema: '*' }, payload => {
|
|
console.log('Change received!', payload)
|
|
})
|
|
.subscribe()
|
|
```
|
|
- id: listen-to-a-specific-table
|
|
name: Listen to a specific table
|
|
js: |
|
|
```js
|
|
supabase
|
|
.channel('public:countries')
|
|
.on('postgres_changes', { event: '*', schema: 'public', table: 'countries' }, payload => {
|
|
console.log('Change received!', payload)
|
|
})
|
|
.subscribe()
|
|
```
|
|
- id: listen-to-inserts
|
|
name: Listen to inserts
|
|
js: |
|
|
```js
|
|
supabase
|
|
.channel('public:countries')
|
|
.on('postgres_changes', { event: 'INSERT', schema: 'public', table: 'countries' }, payload => {
|
|
console.log('Change received!', payload)
|
|
})
|
|
.subscribe()
|
|
```
|
|
- id: listen-to-updates
|
|
name: Listen to updates
|
|
description: |
|
|
By default, Supabase will send only the updated record. If you want to receive the previous values as well you can
|
|
enable full replication for the table you are listening to:
|
|
|
|
```sql
|
|
alter table "your_table" replica identity full;
|
|
```
|
|
js: |
|
|
```js
|
|
supabase
|
|
.channel('public:countries')
|
|
.on('postgres_changes', { event: 'UPDATE', schema: 'public', table: 'countries' }, payload => {
|
|
console.log('Change received!', payload)
|
|
})
|
|
.subscribe()
|
|
```
|
|
- id: listen-to-deletes
|
|
name: Listen to deletes
|
|
description: |
|
|
By default, Supabase does not send deleted records. If you want to receive the deleted record you can
|
|
enable full replication for the table you are listening too:
|
|
|
|
```sql
|
|
alter table "your_table" replica identity full;
|
|
```
|
|
js: |
|
|
```js
|
|
supabase
|
|
.channel('public:countries')
|
|
.on('postgres_changes', { event: 'DELETE', schema: 'public', table: 'countries' }, payload => {
|
|
console.log('Change received!', payload)
|
|
})
|
|
.subscribe()
|
|
```
|
|
- id: listen-to-multiple-events
|
|
name: Listen to multiple events
|
|
description: You can chain listeners if you want to listen to multiple events for each table.
|
|
js: |
|
|
```js
|
|
supabase
|
|
.channel('public:countries')
|
|
.on('postgres_changes', { event: 'INSERT', schema: 'public', table: 'countries' }, handleRecordInserted)
|
|
.on('postgres_changes', { event: 'DELETE', schema: 'public', table: 'countries' }, handleRecordDeleted)
|
|
.subscribe()
|
|
```
|
|
- id: listening-to-row-level-changes
|
|
name: Listen to row level changes
|
|
description: You can listen to individual rows using the format `{table}:{col}=eq.{val}` - where `{col}` is the column name, and `{val}` is the value which you want to match.
|
|
notes: |
|
|
- ``eq`` filter works with all database types as under the hood, it's casting both the filter value and the database value to the correct type and then comparing them.
|
|
js: |
|
|
```js
|
|
supabase
|
|
.channel('public:countries:id=eq.200')
|
|
.on('postgres_changes', { event: 'UPDATE', schema: 'public', table: 'countries', filter: 'id=eq.200' }, handleRecordUpdated)
|
|
.subscribe()
|
|
```
|
|
|
|
- id: getChannels()
|
|
title: 'getChannels()'
|
|
$ref: '@supabase/supabase-js.index.SupabaseClient.getChannels'
|
|
examples:
|
|
- id: get-all-channels
|
|
name: Get all channels
|
|
isSpotlight: true
|
|
js: |
|
|
```js
|
|
const channels = supabase.getChannels()
|
|
```
|
|
|
|
- id: removeChannel()
|
|
title: 'removeChannel()'
|
|
$ref: '@supabase/supabase-js.index.SupabaseClient.removeChannel'
|
|
notes: |
|
|
- Removing a channel is a great way to maintain the performance of your project's Realtime service as well as your database if you're listening to Postgres changes. Supabase will automatically handle cleanup 30 seconds after a client is disconnected, but unused channels may cause degradation as more clients are simultaneously subscribed.
|
|
examples:
|
|
- id: removes-a-channel
|
|
name: Removes a channel
|
|
isSpotlight: true
|
|
js: |
|
|
```js
|
|
supabase.removeChannel(myChannel)
|
|
```
|
|
|
|
- id: removeAllChannels()
|
|
title: 'removeAllChannels()'
|
|
$ref: '@supabase/supabase-js.index.SupabaseClient.removeAllChannels'
|
|
notes: |
|
|
- Removing channels is a great way to maintain the performance of your project's Realtime service as well as your database if you're listening to Postgres changes. Supabase will automatically handle cleanup 30 seconds after a client is disconnected, but unused channels may cause degradation as more clients are simultaneously subscribed.
|
|
examples:
|
|
- id: remove-all-channels
|
|
name: Remove all channels
|
|
isSpotlight: true
|
|
js: |
|
|
```js
|
|
supabase.removeAllChannels()
|
|
```
|
|
|
|
- id: storage.listBuckets()
|
|
title: 'listBuckets()'
|
|
$ref: '@supabase/storage-js.packages/StorageBucketApi.default.listBuckets'
|
|
notes: |
|
|
- RLS policy permissions required:
|
|
- `buckets` table permissions: `select`
|
|
- `objects` table permissions: none
|
|
- Refer to the [Storage guide](/docs/guides/storage/security/access-control) on how access control works
|
|
examples:
|
|
- id: list-buckets
|
|
name: List buckets
|
|
isSpotlight: true
|
|
js: |
|
|
```js
|
|
const { data, error } = await supabase
|
|
.storage
|
|
.listBuckets()
|
|
```
|
|
|
|
- id: storage.getBucket()
|
|
title: 'getBucket()'
|
|
$ref: '@supabase/storage-js.packages/StorageBucketApi.default.getBucket'
|
|
notes: |
|
|
- RLS policy permissions required:
|
|
- `buckets` table permissions: `select`
|
|
- `objects` table permissions: none
|
|
- Refer to the [Storage guide](/docs/guides/storage/security/access-control) on how access control works
|
|
examples:
|
|
- id: get-bucket
|
|
name: Get bucket
|
|
isSpotlight: true
|
|
js: |
|
|
```js
|
|
const { data, error } = await supabase
|
|
.storage
|
|
.getBucket('avatars')
|
|
```
|
|
|
|
- id: storage.createBucket()
|
|
title: 'createBucket()'
|
|
$ref: '@supabase/storage-js.packages/StorageBucketApi.default.createBucket'
|
|
notes: |
|
|
- RLS policy permissions required:
|
|
- `buckets` table permissions: `insert`
|
|
- `objects` table permissions: none
|
|
- Refer to the [Storage guide](/docs/guides/storage/security/access-control) on how access control works
|
|
examples:
|
|
- id: create-bucket
|
|
name: Create bucket
|
|
isSpotlight: true
|
|
js: |
|
|
```js
|
|
const { data, error } = await supabase
|
|
.storage
|
|
.createBucket('avatars', { public: false })
|
|
```
|
|
|
|
- id: storage.emptyBucket()
|
|
title: 'emptyBucket()'
|
|
$ref: '@supabase/storage-js.packages/StorageBucketApi.default.emptyBucket'
|
|
notes: |
|
|
- RLS policy permissions required:
|
|
- `buckets` table permissions: `select`
|
|
- `objects` table permissions: `select` and `delete`
|
|
- Refer to the [Storage guide](/docs/guides/storage/security/access-control) on how access control works
|
|
examples:
|
|
- id: empty-bucket
|
|
name: Empty bucket
|
|
isSpotlight: true
|
|
js: |
|
|
```js
|
|
const { data, error } = await supabase
|
|
.storage
|
|
.emptyBucket('avatars')
|
|
```
|
|
- id: storage.updateBucket()
|
|
title: 'updateBucket()'
|
|
$ref: '@supabase/storage-js.packages/StorageBucketApi.default.updateBucket'
|
|
notes: |
|
|
- RLS policy permissions required:
|
|
- `buckets` table permissions: `update`
|
|
- `objects` table permissions: none
|
|
- Refer to the [Storage guide](/docs/guides/storage/security/access-control) on how access control works
|
|
examples:
|
|
- id: update-bucket
|
|
name: Update bucket
|
|
isSpotlight: true
|
|
js: |
|
|
```js
|
|
const { data, error } = await supabase
|
|
.storage
|
|
.updateBucket('avatars', { public: false })
|
|
```
|
|
|
|
- id: storage.deleteBucket()
|
|
title: 'deleteBucket()'
|
|
$ref: '@supabase/storage-js.packages/StorageBucketApi.default.deleteBucket'
|
|
notes: |
|
|
- RLS policy permissions required:
|
|
- `buckets` table permissions: `select` and `delete`
|
|
- `objects` table permissions: none
|
|
- Refer to the [Storage guide](/docs/guides/storage/security/access-control) on how access control works
|
|
examples:
|
|
- id: delete-bucket
|
|
name: Delete bucket
|
|
isSpotlight: true
|
|
js: |
|
|
```js
|
|
const { data, error } = await supabase
|
|
.storage
|
|
.deleteBucket('avatars')
|
|
```
|
|
|
|
- id: storage.from.upload()
|
|
title: 'from.upload()'
|
|
$ref: '@supabase/storage-js.packages/StorageFileApi.default.upload'
|
|
notes: |
|
|
- RLS policy permissions required:
|
|
- `buckets` table permissions: none
|
|
- `objects` table permissions: `insert`
|
|
- Refer to the [Storage guide](/docs/guides/storage/security/access-control) on how access control works
|
|
- For React Native, using either `Blob`, `File` or `FormData` does not work as intended. Upload file using `ArrayBuffer` from base64 file data instead, see example below.
|
|
examples:
|
|
- id: upload-file
|
|
name: Upload file
|
|
isSpotlight: true
|
|
js: |
|
|
```js
|
|
const avatarFile = event.target.files[0]
|
|
const { data, error } = await supabase
|
|
.storage
|
|
.from('avatars')
|
|
.upload('public/avatar1.png', avatarFile, {
|
|
cacheControl: '3600',
|
|
upsert: false
|
|
})
|
|
```
|
|
- id: upload-file-using`arraybuffer`from-base64-file-data
|
|
name: Upload file using `ArrayBuffer` from base64 file data
|
|
js: |
|
|
```js
|
|
import { decode } from 'base64-arraybuffer'
|
|
|
|
const { data, error } = await supabase
|
|
.storage
|
|
.from('avatars')
|
|
.upload('public/avatar1.png', decode('base64FileData'), {
|
|
contentType: 'image/png'
|
|
})
|
|
```
|
|
|
|
- id: storage.from.update()
|
|
title: 'from.update()'
|
|
$ref: '@supabase/storage-js.packages/StorageFileApi.default.update'
|
|
notes: |
|
|
- RLS policy permissions required:
|
|
- `buckets` table permissions: none
|
|
- `objects` table permissions: `update` and `select`
|
|
- Refer to the [Storage guide](/docs/guides/storage/security/access-control) on how access control works
|
|
- For React Native, using either `Blob`, `File` or `FormData` does not work as intended. Update file using `ArrayBuffer` from base64 file data instead, see example below.
|
|
examples:
|
|
- id: update-file
|
|
name: Update file
|
|
isSpotlight: true
|
|
js: |
|
|
```js
|
|
const avatarFile = event.target.files[0]
|
|
const { data, error } = await supabase
|
|
.storage
|
|
.from('avatars')
|
|
.update('public/avatar1.png', avatarFile, {
|
|
cacheControl: '3600',
|
|
upsert: false
|
|
})
|
|
```
|
|
- id: update-file-using`arraybuffer`from-base64-file-data
|
|
name: Update file using `ArrayBuffer` from base64 file data
|
|
js: |
|
|
```js
|
|
import {decode} from 'base64-arraybuffer'
|
|
|
|
const { data, error } = await supabase
|
|
.storage
|
|
.from('avatars')
|
|
.update('public/avatar1.png', decode('base64FileData'), {
|
|
contentType: 'image/png'
|
|
})
|
|
```
|
|
|
|
- id: storage.from.move()
|
|
title: 'from.move()'
|
|
$ref: '@supabase/storage-js.packages/StorageFileApi.default.move'
|
|
notes: |
|
|
- RLS policy permissions required:
|
|
- `buckets` table permissions: none
|
|
- `objects` table permissions: `update` and `select`
|
|
- Refer to the [Storage guide](/docs/guides/storage/security/access-control) on how access control works
|
|
examples:
|
|
- id: move-file
|
|
name: Move file
|
|
isSpotlight: true
|
|
js: |
|
|
```js
|
|
const { data, error } = await supabase
|
|
.storage
|
|
.from('avatars')
|
|
.move('public/avatar1.png', 'private/avatar2.png')
|
|
```
|
|
|
|
- id: storage.from.copy()
|
|
title: 'from.copy()'
|
|
$ref: '@supabase/storage-js.packages/StorageFileApi.default.copy'
|
|
notes: |
|
|
- RLS policy permissions required:
|
|
- `buckets` table permissions: none
|
|
- `objects` table permissions: `insert` and `select`
|
|
- Refer to the [Storage guide](/docs/guides/storage/security/access-control) on how access control works
|
|
examples:
|
|
- id: copy-file
|
|
name: Copy file
|
|
isSpotlight: true
|
|
js: |
|
|
```js
|
|
const { data, error } = await supabase
|
|
.storage
|
|
.from('avatars')
|
|
.copy('public/avatar1.png', 'private/avatar2.png')
|
|
```
|
|
|
|
- id: storage.from.createSignedUrl()
|
|
title: 'from.createSignedUrl()'
|
|
$ref: '@supabase/storage-js.packages/StorageFileApi.default.createSignedUrl'
|
|
notes: |
|
|
- RLS policy permissions required:
|
|
- `buckets` table permissions: none
|
|
- `objects` table permissions: `select`
|
|
- Refer to the [Storage guide](/docs/guides/storage/security/access-control) on how access control works
|
|
examples:
|
|
- id: create-signed-url
|
|
name: Create Signed URL
|
|
isSpotlight: true
|
|
js: |
|
|
```js
|
|
const { data, error } = await supabase
|
|
.storage
|
|
.from('avatars')
|
|
.createSignedUrl('folder/avatar1.png', 60)
|
|
```
|
|
|
|
- id: storage.from.createSignedUrls()
|
|
title: 'from.createSignedUrls()'
|
|
$ref: '@supabase/storage-js.packages/StorageFileApi.default.createSignedUrls'
|
|
notes: |
|
|
- RLS policy permissions required:
|
|
- `buckets` table permissions: none
|
|
- `objects` table permissions: `select`
|
|
- Refer to the [Storage guide](/docs/guides/storage/security/access-control) on how access control works
|
|
examples:
|
|
- id: create-signed-urls
|
|
name: Create Signed URLs
|
|
isSpotlight: true
|
|
js: |
|
|
```js
|
|
const { data, error } = await supabase
|
|
.storage
|
|
.from('avatars')
|
|
.createSignedUrls(['folder/avatar1.png', 'folder/avatar2.png'], 60)
|
|
```
|
|
|
|
- id: storage.from.getPublicUrl()
|
|
title: 'from.getPublicUrl()'
|
|
$ref: '@supabase/storage-js.packages/StorageFileApi.default.getPublicUrl'
|
|
notes: |
|
|
- The bucket needs to be set to public, either via [updateBucket()](/docs/reference/javascript/storage-updatebucket) or by going to Storage on [supabase.com/dashboard](https://supabase.com/dashboard), clicking the overflow menu on a bucket and choosing "Make public"
|
|
- RLS policy permissions required:
|
|
- `buckets` table permissions: none
|
|
- `objects` table permissions: none
|
|
- Refer to the [Storage guide](/docs/guides/storage/security/access-control) on how access control works
|
|
examples:
|
|
- id: returns-the-url-for-an-asset-in-a-public-bucket
|
|
name: Returns the URL for an asset in a public bucket
|
|
isSpotlight: true
|
|
js: |
|
|
```js
|
|
const { data } = supabase
|
|
.storage
|
|
.from('public-bucket')
|
|
.getPublicUrl('folder/avatar1.png')
|
|
```
|
|
|
|
- id: storage.from.download()
|
|
title: 'from.download()'
|
|
$ref: '@supabase/storage-js.packages/StorageFileApi.default.download'
|
|
notes: |
|
|
- RLS policy permissions required:
|
|
- `buckets` table permissions: none
|
|
- `objects` table permissions: `select`
|
|
- Refer to the [Storage guide](/docs/guides/storage/security/access-control) on how access control works
|
|
examples:
|
|
- id: download-file
|
|
name: Download file
|
|
isSpotlight: true
|
|
js: |
|
|
```js
|
|
const { data, error } = await supabase
|
|
.storage
|
|
.from('avatars')
|
|
.download('folder/avatar1.png')
|
|
```
|
|
|
|
- id: storage.from.remove()
|
|
title: 'from.remove()'
|
|
$ref: '@supabase/storage-js.packages/StorageFileApi.default.remove'
|
|
notes: |
|
|
- RLS policy permissions required:
|
|
- `buckets` table permissions: none
|
|
- `objects` table permissions: `delete` and `select`
|
|
- Refer to the [Storage guide](/docs/guides/storage/security/access-control) on how access control works
|
|
examples:
|
|
- id: delete-file
|
|
name: Delete file
|
|
isSpotlight: true
|
|
js: |
|
|
```js
|
|
const { data, error } = await supabase
|
|
.storage
|
|
.from('avatars')
|
|
.remove(['folder/avatar1.png'])
|
|
```
|
|
|
|
- id: storage.from.list()
|
|
title: 'from.list()'
|
|
$ref: '@supabase/storage-js.packages/StorageFileApi.default.list'
|
|
notes: |
|
|
- RLS policy permissions required:
|
|
- `buckets` table permissions: none
|
|
- `objects` table permissions: `select`
|
|
- Refer to the [Storage guide](/docs/guides/storage/security/access-control) on how access control works
|
|
examples:
|
|
- id: list-files-in-a-bucket
|
|
name: List files in a bucket
|
|
isSpotlight: true
|
|
js: |
|
|
```js
|
|
const { data, error } = await supabase
|
|
.storage
|
|
.from('avatars')
|
|
.list('folder', {
|
|
limit: 100,
|
|
offset: 0,
|
|
sortBy: { column: 'name', order: 'asc' },
|
|
})
|
|
```
|
|
- id: search-files-in-a-bucket
|
|
name: Search files in a bucket
|
|
js: |
|
|
```js
|
|
const { data, error } = await supabase
|
|
.storage
|
|
.from('avatars')
|
|
.list('folder', {
|
|
limit: 100,
|
|
offset: 0,
|
|
sortBy: { column: 'name', order: 'asc' },
|
|
search: 'jon'
|
|
})
|
|
```
|