The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
feat: add updated spec sent from maail
[email protected]14455ac21c39
diff --git a/spec/supabase_swift_v1.yml b/spec/supabase_swift_v1.ymlindex b001fe83718..6919d9e0485 100644--- a/spec/supabase_swift_v1.yml+++ b/spec/supabase_swift_v1.yml@@ -29,6 +29,1744 @@ functions:let client = SupabaseClient(supabaseURL: "https://xyzcompany.supabase.co'", supabaseKey: "public-anon-key")```+ - id: select+ title: 'Fetch data: select()'+ $ref: '@supabase/postgrest-js."lib/PostgrestQueryBuilder".PostgrestQueryBuilder.select'+ notes: |+ - By default, Supabase projects will return a maximum of 1,000 rows. This setting can be changed in Project API Settings. 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 [Modifiers](/docs/reference/javascript/using-modifiers)+ - `select()` can be combined with [Filters](/docs/reference/javascript/using-filters)+ - If using the Supabase hosted platform `apikey` is technically a reserved keyword, since the API gateway will pluck it out for authentication. [It should be avoided as a column name](https://github.com/supabase/supabase/issues/5465).+ - The recommended solution for getting data is to use the value property which will return a decoded model. Create a struct codable model of the of your database to get this easily decoded.+ examples:+ - id: getting-your-data+ name: Getting your data+ isSpotlight: true+ code: |+ ```js+ let city: CityModel = try await client.database+ .from("cities")+ .execute().value+ ```+ - id: selecting-specific-columns+ name: Selecting specific columns+ description: You can select specific fields from your tables.+ code: |+ ```js+ let city: CityModel = try await client.database+ .from("cities")+ .select(columns:"name")+ .execute().value+ ```+ - id: query-foreign-tables+ name: Query foreign tables+ description: If your database has foreign key relationships, you can query related tables too.+ code: |+ ```js+ let country: CountryModel = try await client.database+ .from("countries")+ .select(columns:"""+ id,+ name,+ cities: city_id+ (+ id,+ city_name+ )+ """)+ .execute().value+ ```+ note: |+ What about join tables+ 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 PostgREST engine detects the relationship automatically.+ For more details, [follow the link](https://postgrest.org/en/latest/api.html#embedding-through-join-tables).+ - id: query-the-same-foreign-table-multiple-times+ name: Query the same foreign table multiple times+ description: |+ Sometimes you will need to query the same foreign table twice.+ In this case, you can use the name of the joined column to identify+ which join you intend to use. For convenience, you can also give an+ alias for each column. For example, if we had a shop of products,+ and we wanted to get the supplier and the purchaser at the same time+ (both in the users) table:+ code: |+ ```js+ let message: MessageModel = try await client.database+ .from("messages")+ .select(columns:"""+ content,+ from: sender_id(name),+ to: receiver_id(name)+ """)+ .execute().value+ ```+ - id: querying-with-count-option+ name: Querying with count option+ description: |+ You can get the number of rows by using the count option.+ Allowed values for count option are [exact](https://postgrest.org/en/stable/api.html#exact-count), [planned](https://postgrest.org/en/stable/api.html#planned-count) and [estimated](https://postgrest.org/en/stable/api.html#estimated-count).+ code: |+ ```js+ let count = try await client.database+ .from("countries")+ .select(columns:"*", head: true, count: .exact)+ .execute().count+ ```+ - id: querying-json-data+ name: Querying JSON data+ description: |+ If you have data inside of a JSONB column, you can apply select+ and query filters to the data values. Postgres offers a+ [number of operators](https://www.postgresql.org/docs/current/functions-json.html)+ for querying JSON data. Also see+ [PostgREST docs](http://postgrest.org/en/v7.0.0/api.html#json-columns) for more details.+ code: |+ ```js+ let country: UserModel = try await client.database+ .from("users")+ .select(columns:"""+ id, name+ address->city+ """)+ .execute().value+ ```++ - id: insert+ title: 'Create data: insert()'+ $ref: '@supabase/postgrest-js."lib/PostgrestQueryBuilder".PostgrestQueryBuilder.insert'+ notes: |+ - By default, every time you run `insert()`, the client library will make a `select` to return the full record.+ This is convenient, but it can also cause problems if your Policies are not configured to allow the `select` operation.+ If you are using Row Level Security and you are encountering problems, try setting the `returning` param to `minimal`.+ examples:+ - id: create-a-record+ name: Create a record+ isSpotlight: true+ code: |+ ```js+ let city = CityModel(name:"The Shire", country_id: 554)+ try await client.database+ .from("cities")+ .insert(city)+ .execute()+ ```+ - id: bulk-create+ name: Bulk create+ description: |+ When running a bulk create, the operation is handled in a single transaction. If any of the inserts fail, all other operations are+ rolled back.+ code: |+ ```js+ let theShire = CityModel(name:"The Shire", country_id: 554)+ let rohan = CityModel(name:"Rohan", country_id: 554)+ try await client.database+ .from("cities")+ .insert([theShire, rohan])+ .execute()+ ```+ - id: fetch-inserted-data+ name: Fetch inserted record+ code: |+ ```js+ let theShire = CityModel(name:"The Shire", country_id: 554)+ let rohan = CityModel(name:"Rohan", country_id: 554)+ let cities:[CityModel] = try await client.database+ .from("cities")+ .insert([theShire, rohan],+ returning: .representation)+ .select()+ .execute()+ ```++ - id: update+ title: 'Modify data: update()'+ $ref: '@supabase/postgrest-js."lib/PostgrestQueryBuilder".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+ isSpotlight: true+ code: |+ ```js+ let toUpdate = CountryModel(name: "Austrailia")+ try await client.database+ .from("countries")+ .update(toUpdate)+ .eq(column: "id", value: 1)+ .execute()+ ```+ - id: update-a-record-and-return-it+ name: Update a record and return it+ code: |+ ```js+ let toUpdate = CountryModel(name: "Austrailia")+ try await client.database+ .from("countries")+ .update(toUpdate, returning: .representation)+ .eq(column: "id", value: 1)+ .select()+ .execute()+ ```+ data:+ sql: |+ ```sql+ create table+ countries (id int8 primary key, name text);++ insert into+ countries (id, name)+ values+ (1, 'Taiwan');+ ```+ response: |+ ```json+ {+ "data": [+ {+ "id": 1,+ "name": "Australia"+ }+ ],+ "status": 200,+ "statusText": "OK"+ }+ ```+ hideCodeBlock: true+ - id: updating-json-data+ name: Updating JSON data+ description: |+ Postgres offers a+ [number of operators](https://www.postgresql.org/docs/current/functions-json.html)+ for working with JSON data. Right now it is only possible to update an entire JSON document,+ but we are [working on ideas](https://github.com/PostgREST/postgrest/issues/465) for updating individual keys.+ code: |+ ```js+ let toUpdate = AddressModel(street: "Melrose Place", postcode: 90210)+ try await client.database+ .from("users")+ .update(toUpdate)+ .eq(column: "address->postcode", value: 90210)+ .select()+ .execute()+ ```++ - id: upsert+ title: 'Upsert data: upsert()'+ $ref: '@supabase/postgrest-js."lib/PostgrestQueryBuilder".PostgrestQueryBuilder.upsert'+ notes: |+ - Primary keys should be included in the data payload in order for an update to work correctly.+ - Primary keys must be natural, not surrogate. There are however, [workarounds](https://github.com/PostgREST/postgrest/issues/1118) for surrogate primary keys.+ - If you need to insert new data and update existing data at the same time, use [Postgres triggers](https://github.com/supabase/postgrest-js/issues/173#issuecomment-825124550).+ examples:+ - id: upsert-your-data+ name: Upsert your data+ isSpotlight: true+ code: |+ ```js+ let toUpsert = MessageModel(id:3, message: "foo", username: "supabot")+ try await client.database+ .from("messages")+ .upsert(toUpsert)+ .execute()+ ```+ - id: upserting-into-tables-with-constraints+ name: Upserting into tables with constraints+ description: |+ Running the following will cause supabase to upsert data into the `users` table.+ If the username 'supabot' already exists, the `onConflict` argument tells supabase to overwrite that row+ based on the column passed into `onConflict`.+ isSpotlight: true+ code: |+ ```js+ let toUpsert = UserModel(username: "supabot")+ try await client.database+ .from("users")+ .upsert(toUpsert, onConflict: "username")+ .execute()+ ```+ - name: Return the exact number of rows+ isSpotlight: true+ code: |+ ```js+ let toUpsert = UserModel(username: "supabot")+ try await client.database+ .from("users")+ .upsert(toUpsert, onConflict: "username", count:.exact)+ .execute()+ ```++ - id: delete+ title: 'Delete data: delete()'+ $ref: '@supabase/postgrest-js."lib/PostgrestQueryBuilder".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+ isSpotlight: true+ code: |+ ```js+ try await client.database+ .from("cities")+ .delete()+ .eq(column: "id", value: 666)+ .execute()+ ```+ - id: fetch-delete-records+ name: Fetch deleted records+ code: |+ ```js+ try await client.database+ .from("cities")+ .delete()+ .eq(column: "id", value: 666)+ .select()+ .execute()+ ```+ - id: rpc+ title: 'Stored Procedures: rpc()'+ description: |+ You can call stored procedures as a "Remote Procedure Call".++ That's a fancy way of saying that you can put some logic into your database then call it from anywhere.+ It's especially useful when the logic rarely changes - like password resets and updates.+ examples:+ - id: call-a-stored-procedure+ name: Call a stored procedure+ isSpotlight: true+ description: This is an example invoking a stored procedure.+ code: |+ ```js+ try await client.database+ .rpc(fn: "hello_world")+ .execute()+ ```+ - id: with-parameters+ name: With Parameters+ code: |+ ```js+ let rpcParams = CityModel(name: "The Shire")+ try await client.database+ .rpc(fn: "echo_city", params:rpcParams)+ .execute()+ ```+ - id: using-filters+ title: Using Filters+ description: |+ Filters allow you to only return rows that match certain conditions.++ Filters can be used on `select()`, `update()`, and `delete()` queries.++ If a Database function returns a table response, you can also apply filters.+ examples:+ - id: applying-filters+ name: Applying Filters+ description: |+ Filters must be applied after any of `select()`, `update()`, `upsert()`,+ `delete()`, and `rpc()` and before+ [modifiers](/docs/reference/dart/using-modifiers).+ code: |+ ```js+ try await client.database+ .from("cities")+ .select(columns: "name, country_id")+ .eq(column: "name", value: "The Shire")+ .execute()+ ```+ - id: chaining-filters+ name: Chaining Filters+ description: |+ Filters must be applied after any of `select()`, `update()`, `upsert()`,+ `delete()`, and `rpc()` and before+ [modifiers](/docs/reference/dart/using-modifiers).+ code: |+ ```js+ try await client.database+ .from("cities")+ .select(columns: "name, country_id")+ .gte(column: "population", value: 1000)+ .lt(column: "population", value: 10000)+ .execute()+ ```+ - id: conditional-chaining+ name: Conditional Chaining+ description: |+ Filters can be built up one step at a time and then executed. For example:+ code: |+ ```js+ try await client.database+ .from("users")+ .select()+ .eq(column: "address->postcode", value: 90210)+ .execute()+ ```+ - id: filter-by-value-within-json-column+ name: Filter by values within a JSON column+ description: |+ Filters can be built up one step at a time and then executed. For example:+ data:+ sql: |+ ```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);+ ```+ response: |+ ```json+ {+ "data": [+ {+ "id": 1,+ "name": "Michael",+ "address": {+ "postcode": 90210+ }+ }+ ],+ "status": 200,+ "statusText": "OK"+ }+ ```+ code: |+ ```js+ try await client.database+ .from("users")+ .select()+ .eq(column: "address->postcode", value: 90210)+ .execute()+ ```+ - id: filter-foreign-tables+ name: Filter Foreign Tables+ code: |+ ```js+ try await client.database+ .from("countries")+ .select("""+ name,+ cities!inner (+ name+ )+ """)+ .eq(column: "cities.name", value: "Bali")+ .execute()+ ```+ 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, 2, 'Bali'),+ (2, 1, 'Munich');+ ```+ response: |+ ```json+ {+ "data": [+ {+ "name": "Indonesia",+ "cities": [+ {+ "name": "Bali"+ }+ ]+ }+ ],+ "status": 200,+ "statusText": "OK"+ }+ ```+ - id: or+ title: or()+ description: |+ Finds all rows satisfying at least one of the filters.+ notes: |+ - `.or()` expects you to use the raw [PostgREST syntax](https://postgrest.org/en/stable/api.html#horizontal-filtering-rows) for the filter names and values.++ ```dart+ .or('id.in.(6,7),arraycol.cs.{"a","b"}') // Use Postgres list () and 'in' for in_ filter. Array {} and 'cs' for contains.+ .or('id.in.(${mylist.join(',')}),arraycol.cs.{${mylistArray.join(',')}}') // You can insert a Dart list for list or array column.+ .or('id.in.(${mylist.join(',')}),rangecol.cs.(${mylistRange.join(',')}]') // You can insert a Dart list for list or range column.+ ```+ examples:+ - id: with-select+ name: With `select()`+ isSpotlight: true+ code: |+ ```js+ try await client.database+ .from("countries")+ .select("name")+ .or(filters: "id.eq.2,name.eq.Algeria")+ .execute()+ ```+ - id: use-or-with-and+ name: Use `or` with `and`+ code: |+ ```js+ try await client.database+ .from("countries")+ .select("name")+ .or(filters: "id.gt.3,and(id.eq.1,name.eq.Afghanistan)")+ .execute()+ ```++ - id: not+ title: not()+ description: |+ Finds all rows which doesn't satisfy the filter.+ notes: |+ - `.not()` expects you to use the raw [PostgREST syntax](https://postgrest.org/en/stable/api.html#horizontal-filtering-rows) for the filter names and values.++ ```dart+ .not('name','eq','Paris')+ .not('arraycol','cs','{"a","b"}') // Use Postgres array {} for array column and 'cs' for contains.+ .not('rangecol','cs','(1,2]') // Use Postgres range syntax for range column.+ .not('id','in','(6,7)') // Use Postgres list () and 'in' for in_ filter.+ .not('id','in','(${mylist.join(',')})') // You can insert a Dart list array.+ ```+ examples:+ - id: with-select+ name: With `select()`+ isSpotlight: true+ code: |+ ```js+ try await client.database+ .from("countries")+ .select()+ .not(column: "name", operator: .is, value: "")+ .execute()+ ```++ - id: match+ title: match()+ description: |+ Finds all rows whose columns match the specified `query` object.+ examples:+ - id: with-select+ name: With `select()`+ isSpotlight: true+ code: |+ ```js+ try await client.database+ .from("countries")+ .select("name")+ .match(query: ["id" : 2, "name": "Albania"])+ .execute()+ ```++ - id: eq+ title: eq()+ description: |+ Finds all rows whose value on the stated `column` exactly matches the specified `value`.+ examples:+ - id: with-select+ name: With `select()`+ isSpotlight: true+ code: |+ ```js+ try await client.database+ .from("cities")+ .select(columns: "name, country_id")+ .eq(column: "name", value: "The Shire")+ .execute()+ ```+ - id: with-update+ name: With `update()`+ code: |+ ```js+ let toUpdate = CityModel(name: "Mordor")+ try await client.database+ .from("cities")+ .update(columns: toUpdate)+ .eq(column: "name", value: "San Francisco")+ .execute()+ ```+ - id: with-delete+ name: With `delete()`+ code: |+ ```js+ try await client.database+ .from("cities")+ .delete()+ .eq(column: "name", value: "Mordor")+ .execute()+ ```+ - id: with-rpc+ name: With `rpc()`+ code: |+ ```js+ try await client.database+ .from("cities")+ .delete()+ .eq(column: "name", value: "Mordor")+ .execute()+ ```++ - id: neq+ title: neq()+ description: |+ Finds all rows whose value on the stated `column` doesn't match the specified `value`.+ examples:+ - id: with-select+ name: With `select()`+ isSpotlight: true+ code: |+ ```js+ try await client.database+ .from("cities")+ .select(columns: "name, country_id")+ .neq(column: "name", value: "The Shire")+ .execute()+ ```+ - id: with-update+ name: With `update()`+ code: |+ ```js+ let toUpdate = CityModel(name: "Mordor")+ try await client.database+ .from("cities")+ .update(columns: toUpdate)+ .neq(column: "name", value: "San Francisco")+ .execute()+ ```+ - id: with-delete+ name: With `delete()`+ code: |+ ```js+ try await client.database+ .from("cities")+ .delete()+ .neq(column: "name", value: "Mordor")+ .execute()+ ```+ - id: with-rpc+ name: With `rpc()`+ code: |+ ```js+ try await client.database+ .rpc(fn: "echo_all_cities")+ .neq(column: "address->postcode", value: 90210)+ .execute()+ ```++ - id: gt+ title: gt()+ description: |+ Finds all rows whose value on the stated `column` is greater than the specified `value`.+ examples:+ - id: with-select+ name: With `select()`+ isSpotlight: true+ code: |+ ```js+ try await client.database+ .from("cities")+ .select(columns: "name, country_id")+ .gt(column: "country_id", value: 250)+ .execute()+ ```+ - id: with-update+ name: With `update()`+ code: |+ ```js+ let toUpdate = CityModel(name: "Mordor")+ try await client.database+ .from("cities")+ .update(columns: toUpdate)+ .gt(column: "country_id", value: 250)+ .execute()+ ```+ - id: with-delete+ name: With `delete()`+ code: |+ ```js+ try await client.database+ .from("cities")+ .delete()+ .gt(column: "country_id", value: 250)+ .execute()+ ```+ - id: with-rpc+ name: With `rpc()`+ code: |+ ```js+ try await client.database+ .rpc(fn: "echo_all_cities")+ .gt(column: "country_id", value: 250)+ .execute()+ ```++ - id: gte+ title: gte()+ description: |+ Finds all rows whose value on the stated `column` is greater than or equal to the specified `value`.+ examples:+ - id: with-select+ name: With `select()`+ isSpotlight: true+ code: |+ ```js+ try await client.database+ .from("cities")+ .select(columns: "name, country_id")+ .gte(column: "country_id", value: 250)+ .execute()+ ```+ - id: with-update+ name: With `update()`+ code: |+ ```js+ let toUpdate = CityModel(name: "Mordor")+ try await client.database+ .from("cities")+ .update(columns: toUpdate)+ .gte(column: "country_id", value: 250)+ .execute()+ ```+ - id: with-delete+ name: With `delete()`+ code: |+ ```js+ try await client.database+ .from("cities")+ .delete()+ .gte(column: "country_id", value: 250)+ .execute()+ ```+ - id: with-rpc+ name: With `rpc()`+ code: |+ ```js+ try await client.database+ .rpc(fn: "echo_all_cities")+ .gte(column: "country_id", value: 250)+ .execute()+ ```++ - id: lt+ title: lt()+ description: |+ Finds all rows whose value on the stated `column` is less than the specified `value`.+ examples:+ - id: with-select+ name: With `select()`+ isSpotlight: true+ code: |+ ```js+ try await client.database+ .from("cities")+ .select(columns: "name, country_id")+ .lt(column: "country_id", value: 250)+ .execute()+ ```+ - id: with-update+ name: With `update()`+ code: |+ ```js+ let toUpdate = CityModel(name: "Mordor")+ try await client.database+ .from("cities")+ .update(columns: toUpdate)+ .lt(column: "country_id", value: 250)+ .execute()+ ```+ - id: with-delete+ name: With `delete()`+ code: |+ ```js+ try await client.database+ .from("cities")+ .delete()+ .lt(column: "country_id", value: 250)+ .execute()+ ```+ - id: with-rpc+ name: With `rpc()`+ code: |+ ```js+ try await client.database+ .rpc(fn: "echo_all_cities")+ .lt(column: "country_id", value: 250)+ .execute()+ ```++ - id: lte+ title: lte()+ description: |+ Finds all rows whose value on the stated `column` is less than or equal to the specified `value`.+ $ref: '@supabase/postgrest-js.PostgrestFilterBuilder.lte'+ examples:+ - id: with-select+ name: With `select()`+ isSpotlight: true+ code: |+ ```js+ try await client.database+ .from("cities")+ .select(columns: "name, country_id")+ .lte(column: "country_id", value: 250)+ .execute()+ ```+ - id: with-update+ name: With `update()`+ code: |+ ```js+ let toUpdate = CityModel(name: "Mordor")+ try await client.database+ .from("cities")+ .update(columns: toUpdate)+ .lte(column: "country_id", value: 250)+ .execute()+ ```+ - id: with-delete+ name: With `delete()`+ code: |+ ```js+ try await client.database+ .from("cities")+ .delete()+ .lte(column: "country_id", value: 250)+ .execute()+ ```+ - id: with-rpc+ name: With `rpc()`+ code: |+ ```js+ try await client.database+ .rpc(fn: "echo_all_cities")+ .lte(column: "country_id", value: 250)+ .execute()+ ```++ - id: like+ title: like()+ description: |+ Finds all rows whose value in the stated `column` matches the supplied `pattern` (case sensitive).+ $ref: '@supabase/postgrest-js.PostgrestFilterBuilder.lte'+ examples:+ - id: with-select+ name: With `select()`+ isSpotlight: true+ code: |+ ```js+ try await client.database+ .from("cities")+ .select(columns: "name, country_id")+ .like(column: "name", value: "%la%")+ .execute()+ ```+ - id: with-update+ name: With `update()`+ code: |+ ```js+ let toUpdate = CityModel(name: "Mordor")+ try await client.database+ .from("cities")+ .update(columns: toUpdate)+ .like(column: "name", value: "%la%")+ .execute()+ ```+ - id: with-delete+ name: With `delete()`+ code: |+ ```js+ try await client.database+ .from("cities")+ .delete()+ .like(column: "name", value: "%la%")+ .execute()+ ```+ - id: with-rpc+ name: With `rpc()`+ code: |+ ```js+ try await client.database+ .rpc(fn: "echo_all_cities")+ .like(column: "name", value: "%la%")+ .execute()+ ```++ - id: ilike+ title: ilike()+ description: |+ Finds all rows whose value in the stated `column` matches the supplied `pattern` (case insensitive).+ examples:+ - id: with-select+ name: With `select()`+ isSpotlight: true+ code: |+ ```js+ try await client.database+ .from("cities")+ .select(columns: "name, country_id")+ .ilike(column: "name", value: "%la%")+ .execute()+ ```+ - id: with-update+ name: With `update()`+ code: |+ ```js+ let toUpdate = CityModel(name: "Mordor")+ try await client.database+ .from("cities")+ .update(columns: toUpdate)+ .ilike(column: "name", value: "%la%")+ .execute()+ ```+ - id: with-delete+ name: With `delete()`+ code: |+ ```js+ try await client.database+ .from("cities")+ .delete()+ .ilike(column: "name", value: "%la%")+ .execute()+ ```+ - id: with-rpc+ name: With `rpc()`+ code: |+ ```js+ try await client.database+ .rpc(fn: "echo_all_cities")+ .ilike(column: "name", value: "%la%")+ .execute()+ ```++ - id: is+ title: is_()+ description: |+ A check for exact equality (null, true, false), finds all rows whose value on the stated `column` exactly match the specified `value`.++ `is_` and `in_` filter methods are suffixed with `_` to avoid collisions with reserved keywords.+ examples:+ - id: with-select+ name: With `select()`+ isSpotlight: true+ code: |+ ```js+ try await client.database+ .from("cities")+ .select(columns: "name, country_id")+ .is(column: "name", value: "null")+ .execute()+ ```+ - id: with-update+ name: With `update()`+ code: |+ ```js+ let toUpdate = CityModel(name: "Mordor")+ try await client.database+ .from("cities")+ .update(columns: toUpdate)+ .is(column: "name", value: "null")+ .execute()+ ```+ - id: with-delete+ name: With `delete()`+ code: |+ ```js+ try await client.database+ .from("cities")+ .delete()+ .is(column: "name", value: "null")+ .execute()+ ```+ - id: with-rpc+ name: With `rpc()`+ code: |+ ```js+ try await client.database+ .rpc(fn: "echo_all_cities")+ .is(column: "name", value: "null")+ .execute()+ ```++ - id: in+ title: in_()+ description: |+ Finds all rows whose value on the stated `column` is found on the specified `values`.+ examples:+ - id: with-select+ name: With `select()`+ isSpotlight: true+ code: |+ ```js+ try await client.database+ .from("cities")+ .select(columns: "name, country_id")+ .in(column: "name", value: ["Rio de Janeiro", "San Francisco"])+ .execute()+ ```+ - id: with-update+ name: With `update()`+ code: |+ ```js+ let toUpdate = CityModel(name: "Mordor")+ try await client.database+ .from("cities")+ .update(columns: toUpdate)+ .in(column: "name", value: ["Rio de Janeiro", "San Francisco"])+ .execute()+ ```+ - id: with-delete+ name: With `delete()`+ code: |+ ```js+ try await client.database+ .from("cities")+ .delete()+ .in(column: "name", value: ["Rio de Janeiro", "San Francisco"])+ .execute()+ ```+ - id: with-rpc+ name: With `rpc()`+ code: |+ ```js+ try await client.database+ .from("cities")+ .delete()+ .in(column: "name", value: ["Rio de Janeiro", "San Francisco"])+ .execute()+ ```++ - id: contains+ title: contains()+ examples:+ - id: with-select+ name: With `select()`+ isSpotlight: true+ code: |+ ```js+ try await client.database+ .from("cities")+ .select(columns: "name, id, main_exports")+ .contains(column: "main_exports", value: "oil")+ .execute()+ ```+ - id: with-update+ name: With `update()`+ code: |+ ```js+ let toUpdate = CityModel(name: "Mordor")+ try await client.database+ .from("cities")+ .update(columns: toUpdate)+ .contains(column: "main_exports", value: "oil")+ .execute()+ ```+ - id: with-delete+ name: With `delete()`+ code: |+ ```js+ try await client.database+ .from("cities")+ .delete()+ .contains(column: "main_exports", value: "oil")+ .execute()+ ```+ - id: with-rpc+ name: With `rpc()`+ code: |+ ```js+ try await client.database+ .rpc(fn: "echo_all_cities")+ .contains(column: "main_exports", value: "oil")+ .execute()+ ```++ - id: range-lt+ title: rangeLt()+ examples:+ - id: with-select+ name: With `select()`+ isSpotlight: true+ code: |+ ```js+ try await client.database+ .from("reservations")+ .select()+ .rangeLt(column: "during", value: "[2000-01-02 08:30, 2000-01-02 09:30]")+ .execute()+ ```++ - id: range-gt+ title: rangeGt()+ examples:+ - id: with-select+ name: With `select()`+ isSpotlight: true+ code: |+ ```js+ try await client.database+ .from("reservations")+ .select()+ .rangeGt(column: "during", value: "[2000-01-02 08:30, 2000-01-02 09:30]")+ .execute()+ ```++ - id: range-gte+ title: rangeGte()+ examples:+ - id: with-select+ name: With `select()`+ isSpotlight: true+ code: |+ ```js+ try await client.database+ .from("reservations")+ .select()+ .rangeGte(column: "during", value: "[2000-01-02 08:30, 2000-01-02 09:30]")+ .execute()+ ```++ - id: range-lte+ title: rangeLte()+ $ref: '@supabase/postgrest-js.PostgrestFilterBuilder.rangeLte'+ examples:+ - id: with-select+ name: With `select()`+ isSpotlight: true+ code: |+ ```js+ try await client.database+ .from("reservations")+ .select()+ .rangeLte(column: "during", value: "[2000-01-02 08:30, 2000-01-02 09:30]")+ .execute()+ ```++ - id: range-adjacent+ title: rangeAdjacent()+ examples:+ - id: with-select+ name: With `select()`+ isSpotlight: true+ code: |+ ```js+ try await client.database+ .from("reservations")+ .select()+ .rangeAdjacent(column: "during", value: "[2000-01-02 08:30, 2000-01-02 09:30]")+ .execute()+ ```++ - id: overlaps+ title: overlaps()+ $ref: '@supabase/postgrest-js.PostgrestFilterBuilder.overlaps'+ examples:+ - id: on-array-columns+ name: On array columns+ code: |+ ```js+ try await client.database+ .from("issues")+ .select("title")+ .overlaps(column: "tags", value: "['is:closed', 'severity:high']")+ .execute()+ ```+ data:+ sql: |+ ```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']);+ ```+ response: |+ ```json+ {+ "data": [+ {+ "title": "Cache invalidation is not working"+ }+ ],+ "status": 200,+ "statusText": "OK"+ }+ ```+ hideCodeBlock: true+ isSpotlight: true+ - id: on-range-columns+ name: On range columns+ code: |+ ```js+ try await client.database+ .from("issues")+ .select("title")+ .overlaps(column: "tags", value: "['is:closed', 'severity:high']")+ .execute()+ ```+ data:+ sql: |+ ```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)');+ ```+ response: |+ ```json+ {+ "data": [+ {+ "id": 1,+ "room_name": "Emerald",+ "during": "[\"2000-01-01 13:00:00\",\"2000-01-01 15:00:00\")"+ }+ ],+ "status": 200,+ "statusText": "OK"+ }+ ```+ 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.+ hideCodeBlock: true++ - id: text-search+ title: textSearch()+ description: |+ Only relevant for text and tsvector columns. Match only rows where `column`matches the query string in `query`.++ For more information, see [Postgres full text search](https://supabase.com/docs/guides/database/full-text-search).+ examples:+ - id: text-search+ name: Text search+ code: |+ ```js+ try await client.database+ .from("quotes")+ .select("catchphrase")+ .textSearch(column: "catchphrase",+ query: "'fat' & 'cat'",+ config: "english")+ .execute()+ ```+ - id: basic-normalization+ name: Basic normalization+ description: Uses PostgreSQL's `plainto_tsquery` function.+ code: |+ ```js+ try await client.database+ .from("quotes")+ .select("catchphrase")+ .textSearch(column: "catchphrase",+ query: "'fat' & 'cat'",+ config: "english",+ type: .plain)+ .execute()+ ```+ - id: full-normalization+ name: Full normalization+ description: Uses PostgreSQL's `phraseto_tsquery` function.+ code: |+ ```js+ try await client.database+ .from("quotes")+ .select("catchphrase")+ .textSearch(column: "catchphrase",+ query: "'fat' & 'cat'",+ config: "english",+ type: .phrase)+ .execute()+ ```+ - id: web-search+ 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.++ code: |+ ```js+ try await client.database+ .from("quotes")+ .select("catchphrase")+ .textSearch(column: "catchphrase",+ query: "'fat' & 'cat'",+ config: "english",+ type: .websearch)+ .execute()+ ```++ - id: filter+ title: 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()`+ code: |+ ```js+ try await client.database+ .from("countries")+ .select()+ .filter(column: "name", operator: .in, value: "('Algeria','Japan')")+ .execute()+ ```+ data:+ sql: |+ ```sql+ create table+ countries (id int8 primary key, name text);++ insert into+ countries (id, name)+ values+ (1, 'Afghanistan'),+ (2, 'Albania'),+ (3, 'Algeria');+ ```+ response: |+ ```json+ {+ "data": [+ {+ "id": 3,+ "name": "Algeria"+ }+ ],+ "status": 200,+ "statusText": "OK"+ }+ ```+ hideCodeBlock: true+ isSpotlight: true+ - id: on-a-foreign-table+ name: On a foreign table+ code: |+ ```js+ try await client.database+ .from("countries")+ .select(column:+ """+ name,+ cities!inner (+ name+ )+ """)+ .filter(column: "cities.name", operator: .eq, value: "Bali")+ .execute()+ ```+ 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, 2, 'Bali'),+ (2, 1, 'Munich');+ ```+ response: |+ ```json+ {+ "data": [+ {+ "name": "Indonesia",+ "cities": [+ {+ "name": "Bali"+ }+ ]+ }+ ],+ "status": 200,+ "statusText": "OK"+ }+ ```+ hideCodeBlock: true+ - id: using-modifiers+ title: Using Modifiers+ description: |+ Filters work on the row level—they allows 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+ title: select()+ $ref: '@supabase/postgrest-js.PostgrestTransformBuilder.select'+ examples:+ - id: with-upsert+ name: With `upsert()`+ code: |+ ```js+ try await client.database+ .from("countries")+ .upsert(CountryModel(id: 1, name: "Algeria"))+ .select()+ .execute()+ ```+ data:+ sql: |+ ```sql+ create table+ countries (id int8 primary key, name text);++ insert into+ countries (id, name)+ values+ (1, 'Afghanistan');+ ```+ response: |+ ```json+ {+ "data": [+ {+ "id": 1,+ "name": "Algeria"+ }+ ],+ "status": 201,+ "statusText": "Created"+ }+ ```+ hideCodeBlock: true+ isSpotlight: true+ - id: order+ title: order()+ $ref: '@supabase/postgrest-js.PostgrestTransformBuilder.order'+ examples:+ - id: with-select+ name: With `select()`+ code: |+ ```js+ try await client.database+ .from("countries")+ .select(column: "id, name")+ .order(column: "id", ascending: false)+ .execute()+ ```+ data:+ sql: |+ ```sql+ create table+ countries (id int8 primary key, name text);++ insert into+ countries (id, name)+ values+ (1, 'Afghanistan'),+ (2, 'Albania'),+ (3, 'Algeria');+ ```+ response: |+ ```json+ {+ "data": [+ {+ "id": 3,+ "name": "Algeria"+ },+ {+ "id": 2,+ "name": "Albania"+ },+ {+ "id": 1,+ "name": "Afghanistan"+ }+ ],+ "status": 200,+ "statusText": "OK"+ }+ ```+ hideCodeBlock: true+ isSpotlight: true+ - id: on-a-foreign-table+ name: On a foreign table+ code: |+ ```js+ try await client.database+ .from("countries")+ .select(column:+ """+ name,+ cities (+ name+ )+ """)+ .order(column: "name", ascending: false, foreignTable: "cities")+ .execute()+ ```+ 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, 'United States'),+ (2, 'Vanuatu');+ insert into+ cities (id, country_id, name)+ values+ (1, 1, 'Atlanta'),+ (2, 1, 'New York City');+ ```+ response: |+ ```json+ {+ "data": [+ {+ "name": "United States",+ "cities": [+ {+ "name": "New York City"+ },+ {+ "name": "Atlanta"+ }+ ]+ },+ {+ "name": "Vanuatu",+ "cities": []+ }+ ],+ "status": 200,+ "statusText": "OK"+ }+ ```+ description: |+ Ordering on foreign tables doesn't affect the ordering of+ the parent table.+ hideCodeBlock: true++ - id: limit+ title: limit()+ $ref: '@supabase/postgrest-js.PostgrestTransformBuilder.limit'+ examples:+ - id: with-select+ name: With `select()`+ code: |+ ```js+ try await client.database+ .from("countries")+ .select(column: "id, name")+ .limit(count: 1)+ .execute()+ ```+ data:+ sql: |+ ```sql+ create table+ countries (id int8 primary key, name text);++ insert into+ countries (id, name)+ values+ (1, 'Afghanistan'),+ (2, 'Albania'),+ (3, 'Algeria');+ ```+ response: |+ ```json+ {+ "data": [+ {+ "name": "Afghanistan"+ }+ ],+ "status": 200,+ "statusText": "OK"+ }+ ```+ hideCodeBlock: true+ isSpotlight: true+ - id: on-a-foreign-table+ name: On a foreign table+ code: |+ ```js+ try await client.database+ .from("countries")+ .select(column:+ """+ name,+ cities (+ name+ )+ """)+ .limit(count: 1, foreignTable: "cities")+ .execute()+ ```+ 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, 'United States');+ insert into+ cities (id, country_id, name)+ values+ (1, 1, 'Atlanta'),+ (2, 1, 'New York City');+ ```+ response: |+ ```json+ {+ "data": [+ {+ "name": "United States",+ "cities": [+ {+ "name": "Atlanta"+ }+ ]+ }+ ],+ "status": 200,+ "statusText": "OK"+ }+ ```+ hideCodeBlock: true+ - id: range+ title: range()+ $ref: '@supabase/postgrest-js.PostgrestTransformBuilder.range'+ examples:+ - id: with-select+ name: With `select()`+ code: |+ ```ts+ try await client.database+ .from("countries")+ .select(column:+ """+ name,+ cities (+ name+ )+ """)+ .limit(count: 1, foreignTable: "cities")+ .execute()+ ```+ data:+ sql: |+ ```sql+ create table+ countries (id int8 primary key, name text);++ insert into+ countries (id, name)+ values+ (1, 'Afghanistan'),+ (2, 'Albania'),+ (3, 'Algeria');+ ```+ response: |+ ```json+ {+ "data": [+ {+ "name": "Afghanistan"+ },+ {+ "name": "Albania"+ }+ ],+ "status": 200,+ "statusText": "OK"+ }+ ```+ hideCodeBlock: true+ isSpotlight: true- id: auth-apititle: 'Overview'notes: |@@ -39,15 +1777,726 @@ functions:isSpotlight: truecode: |```js- import { createClient } from '@supabase/supabase-js'+ let supabase = SupabaseClient(supabaseURL: "https://xyzcompany.supabase.co'", supabaseKey: "public-anon-key")+ let auth = supabase.auth+ ```+ - id: sign-up+ 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://app.supabase.com/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.+ - When the user confirms their email address, they are redirected to the [`SITE_URL`](https://supabase.com/docs/reference/auth/config#site_url) by default. You can modify your `SITE_URL` or add additional redirect URLs in [your project](https://app.supabase.com/project/_/auth/url-configuration).+ - If signUp() is called for an existing confirmed user:+ - If **Confirm email** is enabled in [your project](https://app.supabase.com/project/_/auth/providers), an obfuscated/fake user object is returned.+ - If **Confirm email** 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+ code: |+ ```js+ try await supabase.auth.signUp( email: "[email protected]",+ password: "example-password")+ ```+ - id: sign-up-with-additional-user-metadata+ name: Sign up with additional user metadata+ isSpotlight: false+ code: |+ ```js+ try await supabase.auth.signUp( email: "[email protected]",+ password: "example-password",+ data: [+ "first_name": AnyJSON.string("John"),+ "age": AnyJSON.number(24)+ ]+ )+ ```+ - id: sign-up-with-redirect+ name: Sign up with a redirect URL+ description: |+ - See [redirect URLs and wildcards](/docs/guides/auth/overview#redirect-urls-and-wildcards) to add additional redirect URLs to your project.+ code: |+ ```js+ try await supabase.auth.signUp(+ email: "[email protected]",+ password: "example-password",+ redirectTo: URL(string: "https://example.com/welcome")!+ )+ ```+ - id: sign-in-with-password+ 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+ code: |+ ```js+ try await supabase.auth.signIn( email: "[email protected]",+ password: "example-password" )+ ```+ - id: sign-in-with-phone-and-password+ name: Sign in with phone and password+ isSpotlight: false+ code: |+ ```js+ try await supabase.auth.signIn( phone: "+13334445555",+ password: "same-password" )++ try await supabase.auth.verifyOTP(phone: "+13334445555",+ token: "123456",+ type: .sms)+ ```+ - id: sign-in-with-otp+ 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 the user doesn't exist, `signInWithOtp()` will signup the user instead. To restrict this behaviour, you can set `shouldCreateUser` in `SignInWithPasswordlessCredentials.options` to `false`.+ - 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`](/docs/reference/auth/config#site_url).+ - See [redirect URLs and wildcards](/docs/guides/auth/overview#redirect-urls-and-wildcards) to add additional redirect URLs to your project.+ - Magic links and OTPs share the same implementation. To send users a one-time code instead of a magic link, [modify the magic link email template](https://app.supabase.com/project/_/auth/templates) to include `{{ .Token }}` instead of `{{ .ConfirmationURL }}`.+ 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.+ code: |+ ```js+ try await supabase.auth.signInWithOTP(email: "[email protected]",+ redirectTo: URL(string: "https://example.com/welcome")!)+ ```+ - 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.+ code: |+ ```js+ try await supabase.auth.signInWithOTP(phone: "+13334445555")+ ```+ - id: sign-in-with-oauth+ 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+ description: |+ - getOAuthSignInURL() provides the URL which needs to be opened in a SFSafariViewController instance.+ - The redirectTo URL needs to be setup correctly in your project under Authentication -> URL Configuration -> Redirect URLs.+ - For full implementation example check out [Supabase-Swift Github](https://github.com/supabase-community/supabase-swift#social-login-implementation).+ code: |+ ```js+ let url = try await supabase.auth+ .getOAuthSignInURL(+ provider: .github+ )+ ```- const supabase = createClient(supabase_url, anon_key)+ - 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 redirects the user to the URL specified in the `redirectTo` parameter. This parameter defaults to the [`SITE_URL`](/docs/reference/auth/config#site_url). It does not redirect the user immediately after invoking this method.+ - See [redirect URLs and wildcards](/docs/guides/auth/overview#redirect-urls-and-wildcards) to add additional redirect URLs to your project.+ - getOAuthSignInURL() provides the URL which needs to be opened in a SFSafariViewController instance.+ - The redirectTo URL needs to be setup correctly in your project under Authentication -> URL Configuration -> Redirect URLs.+ - For full implementation example check out [Supabase-Swift Github](https://github.com/supabase-community/supabase-swift#social-login-implementation).+ code: |+ ```js+ let url = try await supabase.auth+ .getOAuthSignInURL(+ provider: .google,+ redirectTo: URL(string: "https://example.com/welcome")!+ )```- - id: create-auth-client-server-side- name: Create auth client (server-side)+ - id: sign-in-with-scopes+ name: Sign in with scopesisSpotlight: 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.code: |- ```swift- let supabase = SupabaseClient(supabaseURL: "https://xyzcompany.supabase.co'", supabaseKey: "public-anon-key")- let auth = supabase.auth+ ```js+ let url = try await supabase.auth+ .getOAuthSignInURL(+ provider: .github,+ scopes: "repo gist notifications"+ )+ ```+ - id: sign-out+ 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+ code: |+ ```js+ let url = try await supabase.auth.signOut()+ ```+ - id: verify-otp+ 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+ code: |+ ```js+ try await supabase.auth.verifyOTP(phone: "+13334445555",+ token: "123456",+ type: .sms)+ ```+ - id: verify-signup-one-time-password(otp)+ name: Verify Signup One-Time Password (OTP)+ isSpotlight: false+ code: |+ ```js+ try await supabase.auth.verifyOTP(email: "[email protected]",+ token: "123456",+ type: .signup)+ ```+ - id: get-session+ title: 'getSession()'+ $ref: '@supabase/gotrue-js.GoTrueClient.getSession'+ examples:+ - id: get-the-session-data+ name: Get the session data+ isSpotlight: true+ code: |+ ```js+ try await supabase.auth.session+ ```+ - id: get-user+ 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.+ - Should be used only when you require the most current user data. For faster results, `getSession().session.user` is recommended.+ 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+ code: |+ ```js+ try await supabase.auth.session.user+ ```+ - id: update-user+ 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://app.supabase.com/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+ code: |+ ```js+ try await supabase.auth.update(user: UserAttributes(email: "[email protected]"))+ ```+ - id: update-the-password-for-an-authenticated-user+ name: Update the password for an authenticated user+ isSpotlight: false+ code: |+ ```js+ try await supabase.auth.update(user: UserAttributes(password: "newPassw0rd?"))+ ```+ - id: update-the-users-metadata+ name: Update the user's metadata+ isSpotlight: true+ code: |+ ```js+ try await supabase.auth.update(user:+ UserAttributes(data: [+ "hello": AnyJSON.string("world")+ ]+ )+ ```+ - id: set-session+ 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+ code: |+ ```js+ try await supabase.auth.setSession(accessToken: "access_token", refreshToken: "refresh_token")+ ```+ - id: refresh-session+ title: 'refreshSession()'+ $ref: '@supabase/gotrue-js.GoTrueClient.refreshSession'+ notes: |+ - This method will refresh the session whether the current one is expired or not.+ examples:+ - id: refresh-session-using-the-current-session+ name: Refresh session using the current session+ isSpotlight: true+ code: |+ ```js+ try await supabase.auth.setSessionrefreshSession(refreshToken: "refreshToken")+ ```+ - id: on-auth-state-change+ title: 'onAuthStateChange()'+ $ref: '@supabase/gotrue-js.GoTrueClient.onAuthStateChange'+ notes: |+ - Types of auth events: `SIGNED_IN`, `SIGNED_OUT`, `TOKEN_REFRESHED`, `USER_UPDATED`, `PASSWORD_RECOVERY`+ - Currently, `onAuthStateChange()` does not work across tabs.+ For instance, in the case of a password reset flow, the original tab which requested for the password reset link will not receive the `SIGNED_IN` and `PASSWORD_RECOVERY` event when the user clicks on the link.++ examples:+ - id: listen-to-auth-changes+ name: Listen to auth changes+ isSpotlight: true+ code: |+ ```js+ for await event in supabase.auth.authEventChange {+ let event = event // types of Auth Events+ let session = try? await client.session+ }+ ```+ - id: list-to-a-specific-event+ name: Listen to a specific event+ code: |+ ```js+ for await event in supabase.auth.authEventChange {+ if event == .signedIn {+ //handle signIn+ }+ }+ });+ ```+ - id: invoke+ title: 'invoke()'+ description: |+ Invokes a Supabase Function. See the [guide](/docs/guides/functions) for details on writing Functions.+ notes: |+ - Requires an Authorization header.+ - Invoke params generally match the [Fetch API](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API) spec.+ examples:+ - id: basic-invocation+ name: Basic invocation.+ isSpotlight: true+ code: |+ ```js+ try await supabase.functions.invoke(+ functionName: "hello",+ invokeOptions: body: FooModel(foo: "baa"))+ { data, response in++ }+ ```+ - id: parsing-custom-headers+ name: Parsing custom headers.+ description: |+ Any `headers` will be passed through to the function. A common pattern is to pass a logged-in user's JWT token as an Authorization header.+ isSpotlight: true+ code: |+ ```js+ try await supabase.functions.invoke(+ functionName: "hello",+ invokeOptions:.init(headers:["Authorization": "Bearer ${supabase.auth.currentSession?.accessToken}"],+ body: FooModel(foo: "baa"))+ { data, response in++ }+ ```+ - id: subscribe+ description: |+ Subscribe to realtime changes in your database.+ title: 'on().subscribe()'+ 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).+ - 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;`+ examples:+ - id: connect-to-realtime-client+ name: Connect to RealTime Client+ isSpotlight: true+ code: |+ ```js+ import RealTime++ var client = RealtimeClient(endPoint: "https://yourcompany.supabase.co/realtime/v1", params: ["apikey": "public-anon-key"])+ client.connect()+ ```+ - id: listen-to-all-database-changes+ name: Listen to all database changes+ code: |+ ```js+ let allChanges = client.channel(.all)+ allChanges.on(.all) { message in+ print(message)+ }+ allChanges.subscribe()+ ```+ - id: listen-to-a-specific-table+ name: Listen to a specific table+ code: |+ ```js+ let userChanges = client.channel(.table("users", schema: "public"))+ userChanges.on(.all) { message in+ print(message)+ }+ userChanges.subscribe()+ ```+ - id: listen-to-inserts+ name: Listen to inserts+ code: |+ ```js+ let userChanges = client.channel(.table("users", schema: "public"))+ userChanges.on(.insert) { message in+ print(message)+ }+ userChanges.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 too:++ ```sql+ alter table "your_table" replica identity full;+ ```+ code: |+ ```js+ let userChanges = client.channel(.table("users", schema: "public"))+ userChanges.on(.update) { message in+ print(message)+ }+ userChanges.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;+ ```+ code: |+ ```js+ let userChanges = client.channel(.table("users", schema: "public"))+ userChanges.on(.delete) { message in+ print("delete change: \(message)")+ }+ userChanges.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.+ code: |+ ```js+ let userChanges = client.channel(.table("users", schema: "public"))+ userChanges.on(.insert) { message in+ print("insert change: \(message)")+ }+ userChanges.on(.delete) { message in+ print("delete change: \(message)")+ }+ userChanges.on(.update) { message in+ print("update change: \(message)")+ }+ userChanges.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.+ code: |+ ```js+ let userChanges = client.channel(.column("id", value: "99", table: "users", schema: "public"))+ userChanges.on(.all) { message in+ print(message)+ }+ userChanges.subscribe()+ ```++ - id: remove-channel+ description: |+ Unsubscribes and removes Realtime channel from Realtime client.+ title: '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: Remove a channel+ isSpotlight: true+ code: |+ ```js+ let channel = client.channel(.table("users", schema: "public"))+ client.removeChannel(channel)+ ```+ - id: unsubscribe-channel+ name: Unsubscribe from a channel+ isSpotlight: true+ code: |+ ```js+ let channel = client.channel(.table("users", schema: "public"))+ channel.unsubscribe()+ ```+ - id: list-buckets+ 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#access-control) on how access control works+ examples:+ - id: list-buckets+ name: List buckets+ isSpotlight: true+ code: |+ ```js+ let buckets: [Bucket] = try await supabase.storage.listBuckets()+ ```++ - id: get-bucket+ 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#access-control) on how access control works+ examples:+ - id: get-bucket+ name: Get bucket+ isSpotlight: true+ code: |+ ```js+ try await supabase.storage.getBucket(id: "avatars")+ ```++ - id: create-bucket+ 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#access-control) on how access control works+ examples:+ - id: create-bucket+ name: Create bucket+ isSpotlight: true+ code: |+ ```js+ try await supabase.storage.createBucket(id: "avatars")+ ```++ - id: empty-bucket+ 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#access-control) on how access control works+ examples:+ - id: empty-bucket+ name: Empty bucket+ isSpotlight: true+ code: |+ ```js+ try await supabase.storage.emptyBucket(id: "avatars")+ ```+ - id: delete-bucket+ 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#access-control) on how access control works+ examples:+ - id: delete-bucket+ name: Delete bucket+ isSpotlight: true+ code: |+ ```js+ try await supabase.storage.deleteBucket(id: "avatars")+ ```++ - id: 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#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+ code: |+ ```js+ import SupabaseStorage++ let file = File(name: "avatar1",+ data: fileData,+ fileName: "avatar1.png",+ contentType: "png")++ try await supabase.storage.from(id: "avatars").upload(+ path: "public/avatar1.png",+ file: file,+ fileOptions: FileOptions(cacheControl: "3600")+ )+ ```++ - id: 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#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+ code: |+ ```js+ import SupabaseStorage++ let file = File(name: "avatar2",+ data: fileData,+ fileName: "avatar2.png",+ contentType: "png")++ try await supabase.storage.from(id: "avatars").update(+ path: "public/avatar1.png",+ file: file,+ fileOptions: FileOptions(cacheControl: "3600")+ )+ ```++ - id: 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#access-control) on how access control works+ examples:+ - id: move-file+ name: Move file+ isSpotlight: true+ code: |+ ```js+ try await supabase.storage.+ .from(id: "avatars")+ .move(fromPath: "public/avatar1.png",+ toPath: "public/avatar2.png")+ ```++ - id: from-create-signed-url+ 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#access-control) on how access control works+ examples:+ - id: create-signed-url+ name: Create Signed URL+ isSpotlight: true+ code: |+ ```js+ try await supabase.storage.+ .from(id: "avatars")+ .createSignedURL(path: "avatar1.png", expiresIn: 60)+ ```+ - id: 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#access-control) on how access control works+ examples:+ - id: download-file+ name: Download file+ isSpotlight: true+ code: |+ ```js+ try await supabase.storage.+ .from(id: "avatars")+ .download(path: "public/avatar1.png")+ ```+ - id: 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#access-control) on how access control works+ examples:+ - id: delete-file+ name: Delete file+ isSpotlight: true+ code: |+ ```js+ try await supabase.storage.+ .from(id: "avatars")+ .remove(paths: ["avatar1.png"])+ ```++ - id: 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#access-control) on how access control works+ examples:+ - id: list-files-in-a-bucket+ name: List files in a bucket+ isSpotlight: true+ code: |+ ```js+ try await supabase.storage.+ .from(id: "avatars")+ .list()```++