Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

docs: Add missing sample responses to the Flutter reference docs (#26935)

Tylere402fb90ad63
diff --git a/apps/docs/spec/supabase_dart_v2.yml b/apps/docs/spec/supabase_dart_v2.yml
index 42d8389735c..3872f76ec82 100644
--- a/apps/docs/spec/supabase_dart_v2.yml
+++ b/apps/docs/spec/supabase_dart_v2.yml
@@ -108,6 +108,7 @@ functions:
'public-anon-key',
);
```
+
- id: sign-up
title: 'signUp()'
description: |
@@ -152,7 +153,7 @@ functions:
description: Messaging channel to use (e.g. whatsapp or sms). Defaults to `OtpChannel.sms`.
examples:
- id: sign-up
- name: Sign up.
+ name: Sign up with an email and password
isSpotlight: true
code: |
```dart
@@ -163,6 +164,95 @@ functions:
final Session? session = res.session;
final User? user = res.user;
```
+ response: |
+ ```json
+ // Some fields may be null if "confirm email" is enabled.
+ AuthResponse(
+ user: const User(
+ id: '11111111-1111-1111-1111-111111111111',
+ aud: 'authenticated',
+ role: 'authenticated',
+ email: '[email protected]',
+ emailConfirmedAt: '2024-01-01T00:00:00Z',
+ phone: '',
+ lastSignInAt: '2024-01-01T00:00:00Z',
+ appMetadata: {
+ 'provider': 'email',
+ 'providers': ['email']
+ },
+ userMetadata: {},
+ identities: [
+ UserIdentity(
+ identityId: '22222222-2222-2222-2222-222222222222',
+ id: '11111111-1111-1111-1111-111111111111',
+ userId: '11111111-1111-1111-1111-111111111111',
+ identityData: {
+ 'email': '[email protected]',
+ 'email_verified': false,
+ 'phone_verified': false,
+ 'sub': '11111111-1111-1111-1111-111111111111'
+ },
+ provider: 'email',
+ lastSignInAt: '2024-01-01T00:00:00Z',
+ createdAt: '2024-01-01T00:00:00Z',
+ updatedAt: '2024-01-01T00:00:00Z',
+ ),
+ ],
+ createdAt: '2024-01-01T00:00:00Z',
+ updatedAt: '2024-01-01T00:00:00Z',
+ ),
+ session: Session(
+ accessToken: '<ACCESS_TOKEN>',
+ tokenType: 'bearer',
+ expiresIn: 3600,
+ refreshToken: '<REFRESH_TOKEN>',
+ user: const User(
+ id: '11111111-1111-1111-1111-111111111111',
+ aud: 'authenticated',
+ role: 'authenticated',
+ email: '[email protected]',
+ emailConfirmedAt: '2024-01-01T00:00:00Z',
+ phone: '',
+ lastSignInAt: '2024-01-01T00:00:00Z',
+ appMetadata: {
+ 'provider': 'email',
+ 'providers': ['email']
+ },
+ userMetadata: {},
+ identities: [
+ UserIdentity(
+ identityId: '22222222-2222-2222-2222-222222222222',
+ id: '11111111-1111-1111-1111-111111111111',
+ userId: '11111111-1111-1111-1111-111111111111',
+ identityData: {
+ 'email': '[email protected]',
+ 'email_verified': false,
+ 'phone_verified': false,
+ 'sub': '11111111-1111-1111-1111-111111111111'
+ },
+ provider: 'email',
+ lastSignInAt: '2024-01-01T00:00:00Z',
+ createdAt: '2024-01-01T00:00:00Z',
+ updatedAt: '2024-01-01T00:00:00Z',
+ )
+ ],
+ createdAt: '2024-01-01T00:00:00Z',
+ updatedAt: '2024-01-01T00:00:00Z',
+ ),
+ ),
+ );
+ ```
+ - id: sign-up-phone
+ name: Sign up with a phone number and password (SMS)
+ isSpotlight: true
+ code: |
+ ```dart
+ final AuthResponse res = await supabase.auth.signUp(
+ phone: '123456789',
+ password: 'example-password',
+ channel: OtpChannel.sms,
+ );
+ ```
- id: sign-up-with-metadata
name: Sign up with additional metadata
isSpotlight: true
@@ -179,6 +269,8 @@ functions:
- id: sign-up-with-redirect-url
name: Sign up with redirect URL
isSpotlight: true
+ description: |
+ - See [redirect URLs and wildcards](/docs/guides/auth#redirect-urls-and-wildcards) to add additional redirect URLs to your project.
code: |
```dart
final AuthResponse res = await supabase.auth.signUp(
@@ -213,6 +305,45 @@ functions:
```dart
await supabase.auth.signInAnonymously();
```
+ response: |
+ ```json
+ AuthResponse(
+ user: const User(
+ id: '11111111-1111-1111-1111-111111111111',
+ aud: 'authenticated',
+ role: 'authenticated',
+ email: '',
+ phone: '',
+ lastSignInAt: '2024-01-01T00:00:00Z',
+ appMetadata: {},
+ userMetadata: {},
+ identities: [],
+ createdAt: '2024-01-01T00:00:00Z',
+ updatedAt: '2024-01-01T00:00:00Z',
+ isAnonymous: true,
+ ),
+ session: Session(
+ accessToken: '<ACCESS_TOKEN>',
+ tokenType: 'bearer',
+ expiresIn: 3600,
+ refreshToken: '<REFRESH_TOKEN>',
+ user: const User(
+ id: '11111111-1111-1111-1111-111111111111',
+ aud: 'authenticated',
+ role: 'authenticated',
+ email: '',
+ phone: '',
+ lastSignInAt: '2024-01-01T00:00:00Z',
+ appMetadata: {},
+ userMetadata: {},
+ identities: [],
+ createdAt: '2024-01-01T00:00:00Z',
+ updatedAt: '2024-01-01T00:00:00Z',
+ isAnonymous: true,
+ ),
+ ),
+ );
+ ```
- id: sign-in-anonymously-with-user-metadata
name: Create an anonymous user with custom user metadata
isSpotlight: false
@@ -258,6 +389,83 @@ functions:
final Session? session = res.session;
final User? user = res.user;
```
+ response: |
+ ```json
+ AuthResponse(
+ user: const User(
+ id: '11111111-1111-1111-1111-111111111111',
+ aud: 'authenticated',
+ role: 'authenticated',
+ email: '[email protected]',
+ emailConfirmedAt: '2024-01-01T00:00:00Z',
+ phone: '',
+ lastSignInAt: '2024-01-01T00:00:00Z',
+ appMetadata: {
+ 'provider': 'email',
+ 'providers': ['email']
+ },
+ userMetadata: {},
+ identities: [
+ UserIdentity(
+ identityId: '22222222-2222-2222-2222-222222222222',
+ id: '11111111-1111-1111-1111-111111111111',
+ userId: '11111111-1111-1111-1111-111111111111',
+ identityData: {
+ 'email': '[email protected]',
+ 'email_verified': false,
+ 'phone_verified': false,
+ 'sub': '11111111-1111-1111-1111-111111111111'
+ },
+ provider: 'email',
+ lastSignInAt: '2024-01-01T00:00:00Z',
+ createdAt: '2024-01-01T00:00:00Z',
+ updatedAt: '2024-01-01T00:00:00Z',
+ ),
+ ],
+ createdAt: '2024-01-01T00:00:00Z',
+ updatedAt: '2024-01-01T00:00:00Z',
+ ),
+ session: Session(
+ accessToken: '<ACCESS_TOKEN>',
+ tokenType: 'bearer',
+ expiresIn: 3600,
+ refreshToken: '<REFRESH_TOKEN>',
+ user: const User(
+ id: '11111111-1111-1111-1111-111111111111',
+ aud: 'authenticated',
+ role: 'authenticated',
+ email: '[email protected]',
+ emailConfirmedAt: '2024-01-01T00:00:00Z',
+ phone: '',
+ lastSignInAt: '2024-01-01T00:00:00Z',
+ appMetadata: {
+ 'provider': 'email',
+ 'providers': ['email']
+ },
+ userMetadata: {},
+ identities: [
+ UserIdentity(
+ identityId: '22222222-2222-2222-2222-222222222222',
+ id: '11111111-1111-1111-1111-111111111111',
+ userId: '11111111-1111-1111-1111-111111111111',
+ identityData: {
+ 'email': '[email protected]',
+ 'email_verified': false,
+ 'phone_verified': false,
+ 'sub': '11111111-1111-1111-1111-111111111111'
+ },
+ provider: 'email',
+ lastSignInAt: '2024-01-01T00:00:00Z',
+ createdAt: '2024-01-01T00:00:00Z',
+ updatedAt: '2024-01-01T00:00:00Z',
+ )
+ ],
+ createdAt: '2024-01-01T00:00:00Z',
+ updatedAt: '2024-01-01T00:00:00Z',
+ ),
+ ),
+ );
+ ```
- id: sign-in-with-phone-and-password
name: Sign in with phone and password
code: |
@@ -320,6 +528,13 @@ functions:
emailRedirectTo: kIsWeb ? null : 'io.supabase.flutter://signin-callback/',
);
```
+ response: |
+ ```json
+ AuthResponse(
+ user: null,
+ session: null,
+ );
+ ```
- id: sign-in-with-sms-otp
name: Sign in with SMS OTP.
description: The user will be sent a SMS which contains an OTP. By default, a given user can only request an OTP once every 60 seconds.
@@ -414,6 +629,65 @@ functions:
accessToken: accessToken,
);
```
+ response: |
+ ```json
+ AuthResponse(
+ user: const User(
+ id: '11111111-1111-1111-1111-111111111111',
+ aud: 'authenticated',
+ role: 'authenticated',
+ email: '[email protected]',
+ emailConfirmedAt: '2024-01-01T00:00:00Z',
+ phone: '',
+ lastSignInAt: '2024-01-01T00:00:00Z',
+ appMetadata: {
+ ...
+ },
+ userMetadata: {
+ ...
+ },
+ identities: [
+ UserIdentity(
+ identityId: '22222222-2222-2222-2222-222222222222',
+ provider: 'google',
+ ...
+ ),
+ ],
+ createdAt: '2024-01-01T00:00:00Z',
+ updatedAt: '2024-01-01T00:00:00Z',
+ ),
+ session: Session(
+ accessToken: '<ACCESS_TOKEN>',
+ tokenType: 'bearer',
+ expiresIn: 3600,
+ refreshToken: '<REFRESH_TOKEN>',
+ user: const User(
+ id: '11111111-1111-1111-1111-111111111111',
+ aud: 'authenticated',
+ role: 'authenticated',
+ email: '[email protected]',
+ emailConfirmedAt: '2024-01-01T00:00:00Z',
+ phone: '',
+ lastSignInAt: '2024-01-01T00:00:00Z',
+ appMetadata: {
+ ...
+ },
+ userMetadata: {
+ ...
+ },
+ identities: [
+ UserIdentity(
+ identityId: '22222222-2222-2222-2222-222222222222',
+ provider: 'google',
+ ...
+ )
+ ],
+ createdAt: '2024-01-01T00:00:00Z',
+ updatedAt: '2024-01-01T00:00:00Z',
+ ),
+ ),
+ );
+ ```
- id: sign-in-with-apple
name: Native Apple Sign in
description: You need to [register your app ID with Apple](https://developer.apple.com/help/account/manage-identifiers/register-an-app-id/) with the `Sign In with Apple` capability selected, and add the bundle ID to your Supabase dashboard in `Authentication -> Providers -> Apple` before performing native Apple sign in.
@@ -614,27 +888,104 @@ functions:
type: String
description: Token used in an email link
examples:
- - id: verify-sms-one-time-password(otp)
- name: Verify SMS One-Time Password (OTP)
- isSpotlight: true
+ - id: verify-signup-one-time-password(otp)
+ name: Verify Signup One-Time Password (OTP)
+ isSpotlight: false
code: |
```dart
final AuthResponse res = await supabase.auth.verifyOTP(
- type: OtpType.sms,
- token: '111111',
+ type: OtpType.signup,
+ token: token,
phone: '+13334445555',
);
final Session? session = res.session;
final User? user = res.user;
```
- - id: verify-signup-one-time-password(otp)
- name: Verify Signup One-Time Password (OTP)
- isSpotlight: false
+ response: |
+ ```json
+ AuthResponse(
+ user: const User(
+ id: '11111111-1111-1111-1111-111111111111',
+ aud: 'authenticated',
+ role: 'authenticated',
+ email: '[email protected]',
+ emailConfirmedAt: '2024-01-01T00:00:00Z',
+ phone: '',
+ lastSignInAt: '2024-01-01T00:00:00Z',
+ appMetadata: {
+ 'provider': 'email',
+ 'providers': ['email']
+ },
+ userMetadata: {},
+ identities: [
+ UserIdentity(
+ identityId: '22222222-2222-2222-2222-222222222222',
+ id: '11111111-1111-1111-1111-111111111111',
+ userId: '11111111-1111-1111-1111-111111111111',
+ identityData: {
+ 'email': '[email protected]',
+ 'email_verified': false,
+ 'phone_verified': false,
+ 'sub': '11111111-1111-1111-1111-111111111111'
+ },
+ provider: 'email',
+ lastSignInAt: '2024-01-01T00:00:00Z',
+ createdAt: '2024-01-01T00:00:00Z',
+ updatedAt: '2024-01-01T00:00:00Z',
+ ),
+ ],
+ createdAt: '2024-01-01T00:00:00Z',
+ updatedAt: '2024-01-01T00:00:00Z',
+ ),
+ session: Session(
+ accessToken: '<ACCESS_TOKEN>',
+ tokenType: 'bearer',
+ expiresIn: 3600,
+ refreshToken: '<REFRESH_TOKEN>',
+ user: const User(
+ id: '11111111-1111-1111-1111-111111111111',
+ aud: 'authenticated',
+ role: 'authenticated',
+ email: '[email protected]',
+ emailConfirmedAt: '2024-01-01T00:00:00Z',
+ phone: '',
+ lastSignInAt: '2024-01-01T00:00:00Z',
+ appMetadata: {
+ 'provider': 'email',
+ 'providers': ['email']
+ },
+ userMetadata: {},
+ identities: [
+ UserIdentity(
+ identityId: '22222222-2222-2222-2222-222222222222',
+ id: '11111111-1111-1111-1111-111111111111',
+ userId: '11111111-1111-1111-1111-111111111111',
+ identityData: {
+ 'email': '[email protected]',
+ 'email_verified': false,
+ 'phone_verified': false,
+ 'sub': '11111111-1111-1111-1111-111111111111'
+ },
+ provider: 'email',
+ lastSignInAt: '2024-01-01T00:00:00Z',
+ createdAt: '2024-01-01T00:00:00Z',
+ updatedAt: '2024-01-01T00:00:00Z',
+ )
+ ],
+ createdAt: '2024-01-01T00:00:00Z',
+ updatedAt: '2024-01-01T00:00:00Z',
+ ),
+ ),
+ );
+ ```
+ - id: verify-sms-one-time-password(otp)
+ name: Verify SMS One-Time Password (OTP)
+ isSpotlight: true
code: |
```dart
final AuthResponse res = await supabase.auth.verifyOTP(
- type: OtpType.signup,
- token: token,
+ type: OtpType.sms,
+ token: '111111',
phone: '+13334445555',
);
final Session? session = res.session;
@@ -652,6 +1003,48 @@ functions:
```dart
final Session? session = supabase.auth.currentSession;
```
+ response: |
+ ```json
+ Session(
+ accessToken: '<ACCESS_TOKEN>',
+ tokenType: 'bearer',
+ expiresIn: 3600,
+ refreshToken: '<REFRESH_TOKEN>',
+ user: User(
+ id: '11111111-1111-1111-1111-111111111111',
+ aud: 'authenticated',
+ role: 'authenticated',
+ email: '[email protected]',
+ emailConfirmedAt: '2024-01-01T00:00:00Z',
+ phone: '',
+ lastSignInAt: '2024-01-01T00:00:00Z',
+ appMetadata: {
+ 'provider': 'email',
+ 'providers': ['email']
+ },
+ userMetadata: {},
+ identities: [
+ UserIdentity(
+ identityId: '22222222-2222-2222-2222-222222222222',
+ id: '11111111-1111-1111-1111-111111111111',
+ userId: '11111111-1111-1111-1111-111111111111',
+ identityData: {
+ 'email': '[email protected]',
+ 'email_verified': false,
+ 'phone_verified': false,
+ 'sub': '11111111-1111-1111-1111-111111111111'
+ },
+ provider: 'email',
+ lastSignInAt: '2024-01-01T00:00:00Z',
+ createdAt: '2024-01-01T00:00:00Z',
+ updatedAt: '2024-01-01T00:00:00Z',
+ )
+ ],
+ createdAt: '2024-01-01T00:00:00Z',
+ updatedAt: '2024-01-01T00:00:00Z',
+ ),
+ );
+ ```
- id: get-user
title: 'currentUser'
description: |
@@ -663,6 +1056,42 @@ functions:
```dart
final User? user = supabase.auth.currentUser;
```
+ response: |
+ ```json
+ User(
+ id: '11111111-1111-1111-1111-111111111111',
+ aud: 'authenticated',
+ role: 'authenticated',
+ email: '[email protected]',
+ emailConfirmedAt: '2024-01-01T00:00:00Z',
+ phone: '',
+ lastSignInAt: '2024-01-01T00:00:00Z',
+ appMetadata: {
+ 'provider': 'email',
+ 'providers': ['email']
+ },
+ userMetadata: {},
+ identities: [
+ UserIdentity(
+ identityId: '22222222-2222-2222-2222-222222222222',
+ id: '11111111-1111-1111-1111-111111111111',
+ userId: '11111111-1111-1111-1111-111111111111',
+ identityData: {
+ 'email': '[email protected]',
+ 'email_verified': false,
+ 'phone_verified': false,
+ 'sub': '11111111-1111-1111-1111-111111111111'
+ },
+ provider: 'email',
+ lastSignInAt: '2024-01-01T00:00:00Z',
+ createdAt: '2024-01-01T00:00:00Z',
+ updatedAt: '2024-01-01T00:00:00Z',
+ )
+ ],
+ createdAt: '2024-01-01T00:00:00Z',
+ updatedAt: '2024-01-01T00:00:00Z',
+ );
+ ```
- id: update-user
title: 'updateUser()'
description: |
@@ -715,6 +1144,44 @@ functions:
);
final User? updatedUser = res.user;
```
+ response: |
+ ```json
+ UserResponse(
+ user: const User(
+ id: '11111111-1111-1111-1111-111111111111',
+ aud: 'authenticated',
+ role: 'authenticated',
+ email: '[email protected]',
+ emailConfirmedAt: '2024-01-01T00:00:00Z',
+ phone: '',
+ lastSignInAt: '2024-01-01T00:00:00Z',
+ appMetadata: {
+ 'provider': 'email',
+ 'providers': ['email']
+ },
+ userMetadata: {},
+ identities: [
+ UserIdentity(
+ identityId: '22222222-2222-2222-2222-222222222222',
+ id: '11111111-1111-1111-1111-111111111111',
+ userId: '11111111-1111-1111-1111-111111111111',
+ identityData: {
+ 'email': '[email protected]',
+ 'email_verified': false,
+ 'phone_verified': false,
+ 'sub': '11111111-1111-1111-1111-111111111111'
+ },
+ provider: 'email',
+ lastSignInAt: '2024-01-01T00:00:00Z',
+ createdAt: '2024-01-01T00:00:00Z',
+ updatedAt: '2024-01-01T00:00:00Z',
+ )
+ ],
+ createdAt: '2024-01-01T00:00:00Z',
+ updatedAt: '2024-01-01T00:00:00Z',
+ ),
+ );
+ ```
- id: update-the-password-for-an-authenticated-user
name: Update the password for an authenticated user
isSpotlight: false
@@ -764,6 +1231,26 @@ functions:
```dart
final identities = await supabase.auth.getUserIdentities();
```
+ response: |
+ ```json
+ [
+ UserIdentity(
+ identityId: '22222222-2222-2222-2222-222222222222',
+ id: '2024-01-01T00:00:00Z',
+ userId: '2024-01-01T00:00:00Z',
+ identityData: {
+ 'email': '[email protected]',
+ 'email_verified': false,
+ 'phone_verified': false,
+ 'sub': '11111111-1111-1111-1111-111111111111'
+ },
+ provider: 'email',
+ lastSignInAt: '2024-01-01T00:00:00Z',
+ createdAt: '2024-01-01T00:00:00Z',
+ updatedAt: '2024-01-01T00:00:00Z',
+ )
+ ];
+ ```
- id: link-identity
title: 'linkIdentity()'
description: |
@@ -880,6 +1367,27 @@ functions:
final authSubscription = supabase.auth.onAuthStateChange.listen((data) {
final AuthChangeEvent event = data.event;
final Session? session = data.session;
+
+ print('event: $event, session: $session');
+
+ switch (event) {
+ case AuthChangeEvent.initialSession:
+ // handle initial session
+ case AuthChangeEvent.signedIn:
+ // handle signed in
+ case AuthChangeEvent.signedOut:
+ // handle signed out
+ case AuthChangeEvent.passwordRecovery:
+ // handle password recovery
+ case AuthChangeEvent.tokenRefreshed:
+ // handle token refreshed
+ case AuthChangeEvent.userUpdated:
+ // handle user updated
+ case AuthChangeEvent.userDeleted:
+ // handle user deleted
+ case AuthChangeEvent.mfaChallengeVerified:
+ // handle mfa challenge verified
+ }
});
```
- id: listen-to-a-specific-event
@@ -950,6 +1458,83 @@ functions:
final session = res.session;
```
+ response: |
+ ```json
+ AuthResponse(
+ user: const User(
+ id: '11111111-1111-1111-1111-111111111111',
+ aud: 'authenticated',
+ role: 'authenticated',
+ email: '[email protected]',
+ emailConfirmedAt: '2024-01-01T00:00:00Z',
+ phone: '',
+ lastSignInAt: '2024-01-01T00:00:00Z',
+ appMetadata: {
+ 'provider': 'email',
+ 'providers': ['email']
+ },
+ userMetadata: {},
+ identities: [
+ UserIdentity(
+ identityId: '22222222-2222-2222-2222-222222222222',
+ id: '11111111-1111-1111-1111-111111111111',
+ userId: '11111111-1111-1111-1111-111111111111',
+ identityData: {
+ 'email': '[email protected]',
+ 'email_verified': false,
+ 'phone_verified': false,
+ 'sub': '11111111-1111-1111-1111-111111111111'
+ },
+ provider: 'email',
+ lastSignInAt: '2024-01-01T00:00:00Z',
+ createdAt: '2024-01-01T00:00:00Z',
+ updatedAt: '2024-01-01T00:00:00Z',
+ ),
+ ],
+ createdAt: '2024-01-01T00:00:00Z',
+ updatedAt: '2024-01-01T00:00:00Z',
+ ),
+ session: Session(
+ accessToken: '<ACCESS_TOKEN>',
+ tokenType: 'bearer',
+ expiresIn: 3600,
+ refreshToken: '<REFRESH_TOKEN>',
+ user: const User(
+ id: '11111111-1111-1111-1111-111111111111',
+ aud: 'authenticated',
+ role: 'authenticated',
+ email: '[email protected]',
+ emailConfirmedAt: '2024-01-01T00:00:00Z',
+ phone: '',
+ lastSignInAt: '2024-01-01T00:00:00Z',
+ appMetadata: {
+ 'provider': 'email',
+ 'providers': ['email']
+ },
+ userMetadata: {},
+ identities: [
+ UserIdentity(
+ identityId: '22222222-2222-2222-2222-222222222222',
+ id: '11111111-1111-1111-1111-111111111111',
+ userId: '11111111-1111-1111-1111-111111111111',
+ identityData: {
+ 'email': '[email protected]',
+ 'email_verified': false,
+ 'phone_verified': false,
+ 'sub': '11111111-1111-1111-1111-111111111111'
+ },
+ provider: 'email',
+ lastSignInAt: '2024-01-01T00:00:00Z',
+ createdAt: '2024-01-01T00:00:00Z',
+ updatedAt: '2024-01-01T00:00:00Z',
+ )
+ ],
+ createdAt: '2024-01-01T00:00:00Z',
+ updatedAt: '2024-01-01T00:00:00Z',
+ ),
+ ),
+ );
+ ```
- id: refresh-session
title: 'refreshSession()'
notes: |
@@ -963,6 +1548,83 @@ functions:
final AuthResponse res = await supabase.auth.refreshSession();
final session = res.session;
```
+ response: |
+ ```json
+ AuthResponse(
+ user: User(
+ id: '11111111-1111-1111-1111-111111111111',
+ aud: 'authenticated',
+ role: 'authenticated',
+ email: '[email protected]',
+ emailConfirmedAt: '2024-01-01T00:00:00Z',
+ phone: '',
+ lastSignInAt: '2024-01-01T00:00:00Z',
+ appMetadata: {
+ 'provider': 'email',
+ 'providers': ['email']
+ },
+ userMetadata: {},
+ identities: [
+ UserIdentity(
+ identityId: '22222222-2222-2222-2222-222222222222',
+ id: '11111111-1111-1111-1111-111111111111',
+ userId: '11111111-1111-1111-1111-111111111111',
+ identityData: {
+ 'email': '[email protected]',
+ 'email_verified': false,
+ 'phone_verified': false,
+ 'sub': '11111111-1111-1111-1111-111111111111'
+ },
+ provider: 'email',
+ lastSignInAt: '2024-01-01T00:00:00Z',
+ createdAt: '2024-01-01T00:00:00Z',
+ updatedAt: '2024-01-01T00:00:00Z',
+ ),
+ ],
+ createdAt: '2024-01-01T00:00:00Z',
+ updatedAt: '2024-01-01T00:00:00Z',
+ ),
+ session: Session(
+ accessToken: '<ACCESS_TOKEN>',
+ tokenType: 'bearer',
+ expiresIn: 3600,
+ refreshToken: '<REFRESH_TOKEN>',
+ user: const User(
+ id: '11111111-1111-1111-1111-111111111111',
+ aud: 'authenticated',
+ role: 'authenticated',
+ email: '[email protected]',
+ emailConfirmedAt: '2024-01-01T00:00:00Z',
+ phone: '',
+ lastSignInAt: '2024-01-01T00:00:00Z',
+ appMetadata: {
+ 'provider': 'email',
+ 'providers': ['email']
+ },
+ userMetadata: {},
+ identities: [
+ UserIdentity(
+ identityId: '22222222-2222-2222-2222-222222222222',
+ id: '11111111-1111-1111-1111-111111111111',
+ userId: '11111111-1111-1111-1111-111111111111',
+ identityData: {
+ 'email': '[email protected]',
+ 'email_verified': false,
+ 'phone_verified': false,
+ 'sub': '11111111-1111-1111-1111-111111111111'
+ },
+ provider: 'email',
+ lastSignInAt: '2024-01-01T00:00:00Z',
+ createdAt: '2024-01-01T00:00:00Z',
+ updatedAt: '2024-01-01T00:00:00Z',
+ )
+ ],
+ createdAt: '2024-01-01T00:00:00Z',
+ updatedAt: '2024-01-01T00:00:00Z',
+ ),
+ ),
+ );
+ ```
- id: auth-mfa-api
title: 'Overview'
notes: |
@@ -1006,6 +1668,18 @@ functions:
final qrCodeUrl = res.totp.qrCode;
```
+ response: |
+ ```json
+ AuthMFAEnrollResponse(
+ id: '<ID>',
+ type: FactorType.totp,
+ totp: TOTPEnrollment(
+ qrCode: '<QR_CODE_AS_SVG_DATA>',
+ secret: '<SECRET>',
+ uri: '<URI>',
+ ),
+ );
+ ```
- id: mfa-challenge
title: 'mfa.challenge()'
notes: |
@@ -1027,6 +1701,13 @@ functions:
factorId: '34e770dd-9ff9-416c-87fa-43b31d7ef225',
);
```
+ response: |
+ ```json
+ AuthMFAChallengeResponse(
+ id: '<ID>',
+ expiresAt: DateTime.fromMillisecondsSinceEpoch(1700000000),
+ );
+ ```
- id: mfa-verify
title: 'mfa.verify()'
notes: |
@@ -1057,6 +1738,59 @@ functions:
code: '123456',
);
```
+ response: |
+ ```json
+ AuthMFAVerifyResponse(
+ accessToken: '<ACCESS_TOKEN>',
+ tokenType: 'Bearer',
+ expiresIn: Duration(seconds: 3600),
+ refreshToken: '<REFRESH_TOKEN>',
+ user: User(
+ id: '11111111-1111-1111-1111-111111111111',
+ aud: 'authenticated',
+ role: 'authenticated',
+ email: '[email protected]',
+ emailConfirmedAt: '2024-01-01T00:00:00Z',
+ phone: '',
+ lastSignInAt: '2024-01-01T00:00:00Z',
+ appMetadata: {
+ 'provider': 'email',
+ 'providers': ['email']
+ },
+ userMetadata: {},
+ identities: [
+ UserIdentity(
+ identityId: '22222222-2222-2222-2222-222222222222',
+ id: '11111111-1111-1111-1111-111111111111',
+ userId: '11111111-1111-1111-1111-111111111111',
+ identityData: {
+ 'email': '[email protected]',
+ 'email_verified': false,
+ 'phone_verified': false,
+ 'sub': '11111111-1111-1111-1111-111111111111'
+ },
+ provider: 'email',
+ lastSignInAt: '2024-01-01T00:00:00Z',
+ createdAt: '2024-01-01T00:00:00Z',
+ updatedAt: '2024-01-01T00:00:00Z',
+ ),
+ ],
+ createdAt: '2024-01-01T00:00:00Z',
+ updatedAt: '2024-01-01T00:00:00Z',
+ isAnonymous: false,
+ factors: [
+ Factor(
+ id: '<ID>',
+ friendlyName: 'Important Auth App',
+ factorType: FactorType.totp,
+ status: 'verified',
+ createdAt: '2024-01-01T00:00:00Z',
+ updatedAt: '2024-01-01T00:00:00Z'
+ )
+ ]
+ )
+ );
+ ```
- id: mfa-challenge-and-verify
title: 'mfa.challengeAndVerify()'
notes: |
@@ -1083,6 +1817,59 @@ functions:
code: '123456',
);
```
+ response: |
+ ```json
+ AuthMFAVerifyResponse(
+ accessToken: '<ACCESS_TOKEN>',
+ tokenType: 'Bearer',
+ expiresIn: Duration(seconds: 3600),
+ refreshToken: '<REFRESH_TOKEN>',
+ user: User(
+ id: '11111111-1111-1111-1111-111111111111',
+ aud: 'authenticated',
+ role: 'authenticated',
+ email: '[email protected]',
+ emailConfirmedAt: '2024-01-01T00:00:00Z',
+ phone: '',
+ lastSignInAt: '2024-01-01T00:00:00Z',
+ appMetadata: {
+ 'provider': 'email',
+ 'providers': ['email']
+ },
+ userMetadata: {},
+ identities: [
+ UserIdentity(
+ identityId: '22222222-2222-2222-2222-222222222222',
+ id: '11111111-1111-1111-1111-111111111111',
+ userId: '11111111-1111-1111-1111-111111111111',
+ identityData: {
+ 'email': '[email protected]',
+ 'email_verified': false,
+ 'phone_verified': false,
+ 'sub': '11111111-1111-1111-1111-111111111111'
+ },
+ provider: 'email',
+ lastSignInAt: '2024-01-01T00:00:00Z',
+ createdAt: '2024-01-01T00:00:00Z',
+ updatedAt: '2024-01-01T00:00:00Z',
+ ),
+ ],
+ createdAt: '2024-01-01T00:00:00Z',
+ updatedAt: '2024-01-01T00:00:00Z',
+ isAnonymous: false,
+ factors: [
+ Factor(
+ id: '<ID>',
+ friendlyName: 'Important Auth App',
+ factorType: FactorType.totp,
+ status: 'verified',
+ createdAt: '2024-01-01T00:00:00Z',
+ updatedAt: '2024-01-01T00:00:00Z'
+ )
+ ]
+ )
+ );
+ ```
- id: mfa-unenroll
title: 'mfa.unenroll()'
notes: |
@@ -1103,6 +1890,12 @@ functions:
'34e770dd-9ff9-416c-87fa-43b31d7ef225',
);
```
+ response: |
+ ```json
+ AuthMFAUnenrollResponse(
+ id: '<FACTOR_ID>',
+ );
+ ```
- id: mfa-get-authenticator-assurance-level
title: 'mfa.getAuthenticatorAssuranceLevel()'
notes: |
@@ -1121,6 +1914,19 @@ functions:
final nextLevel = res.nextLevel;
final currentAuthenticationMethods = res.currentAuthenticationMethods;
```
+ response: |
+ ```json
+ AuthMFAGetAuthenticatorAssuranceLevelResponse(
+ currentLevel: AuthenticatorAssuranceLevels.aal1,
+ nextLevel: AuthenticatorAssuranceLevels.aal2,
+ currentAuthenticationMethods: [
+ AMREntry(
+ method: AMRMethod.password,
+ timestamp: DateTime.fromMillisecondsSinceEpoch(1700000000000),
+ )
+ ]
+ }
+ ```
- id: admin-api
title: 'Overview'
notes: |
@@ -1154,6 +1960,44 @@ functions:
final res = await supabase.auth.admin.getUserById(userId);
final user = res.user;
```
+ response: |
+ ```json
+ UserResponse(
+ user: const User(
+ id: '11111111-1111-1111-1111-111111111111',
+ aud: 'authenticated',
+ role: 'authenticated',
+ email: '[email protected]',
+ emailConfirmedAt: '2024-01-01T00:00:00Z',
+ phone: '',
+ lastSignInAt: '2024-01-01T00:00:00Z',
+ appMetadata: {
+ 'provider': 'email',
+ 'providers': ['email']
+ },
+ userMetadata: {},
+ identities: [
+ UserIdentity(
+ identityId: '22222222-2222-2222-2222-222222222222',
+ id: '11111111-1111-1111-1111-111111111111',
+ userId: '11111111-1111-1111-1111-111111111111',
+ identityData: {
+ 'email': '[email protected]',
+ 'email_verified': false,
+ 'phone_verified': false,
+ 'sub': '11111111-1111-1111-1111-111111111111'
+ },
+ provider: 'email',
+ lastSignInAt: '2024-01-01T00:00:00Z',
+ createdAt: '2024-01-01T00:00:00Z',
+ updatedAt: '2024-01-01T00:00:00Z',
+ )
+ ],
+ createdAt: '2024-01-01T00:00:00Z',
+ updatedAt: '2024-01-01T00:00:00Z',
+ ),
+ );
+ ```
- id: list-users
title: 'listUsers()'
notes: |
@@ -1177,6 +2021,44 @@ functions:
// Returns the first 50 users.
final List<User> users = await supabase.auth.admin.listUsers();
```
+ response: |
+ ```json
+ [
+ User(
+ id: '11111111-1111-1111-1111-111111111111',
+ aud: 'authenticated',
+ role: 'authenticated',
+ email: '[email protected]',
+ emailConfirmedAt: '2024-01-01T00:00:00Z',
+ phone: '',
+ lastSignInAt: '2024-01-01T00:00:00Z',
+ appMetadata: {
+ 'provider': 'email',
+ 'providers': ['email']
+ },
+ userMetadata: {},
+ identities: [
+ UserIdentity(
+ identityId: '22222222-2222-2222-2222-222222222222',
+ id: '11111111-1111-1111-1111-111111111111',
+ userId: '11111111-1111-1111-1111-111111111111',
+ identityData: {
+ 'email': '[email protected]',
+ 'email_verified': false,
+ 'phone_verified': false,
+ 'sub': '11111111-1111-1111-1111-111111111111'
+ },
+ provider: 'email',
+ lastSignInAt: '2024-01-01T00:00:00Z',
+ createdAt: '2024-01-01T00:00:00Z',
+ updatedAt: '2024-01-01T00:00:00Z',
+ )
+ ],
+ createdAt: '2024-01-01T00:00:00Z',
+ updatedAt: '2024-01-01T00:00:00Z',
+ )
+ ]
+ ```
- id: get-paginated-list-of-users
name: Paginated list of users
isSpotlight: false
@@ -1245,6 +2127,44 @@ functions:
userMetadata: {'name': 'Yoda'},
));
```
+ response: |
+ ```json
+ UserResponse(
+ user: User(
+ id: '11111111-1111-1111-1111-111111111111',
+ aud: 'authenticated',
+ role: 'authenticated',
+ email: '[email protected]',
+ emailConfirmedAt: '2024-01-01T00:00:00Z',
+ phone: '',
+ lastSignInAt: '2024-01-01T00:00:00Z',
+ appMetadata: {
+ 'provider': 'email',
+ 'providers': ['email']
+ },
+ userMetadata: {'name': 'Yoda'},
+ identities: [
+ UserIdentity(
+ identityId: '22222222-2222-2222-2222-222222222222',
+ id: '11111111-1111-1111-1111-111111111111',
+ userId: '11111111-1111-1111-1111-111111111111',
+ identityData: {
+ 'email': '[email protected]',
+ 'email_verified': false,
+ 'phone_verified': false,
+ 'sub': '11111111-1111-1111-1111-111111111111'
+ },
+ provider: 'email',
+ lastSignInAt: '2024-01-01T00:00:00Z',
+ createdAt: '2024-01-01T00:00:00Z',
+ updatedAt: '2024-01-01T00:00:00Z',
+ )
+ ],
+ createdAt: '2024-01-01T00:00:00Z',
+ updatedAt: '2024-01-01T00:00:00Z',
+ ),
+ );
+ ```
- id: auto-confirm-the-users-email
name: Auto-confirm the user's email
code: |
@@ -1309,6 +2229,44 @@ functions:
.inviteUserByEmail('[email protected]');
final User? user = res.user;
```
+ response: |
+ ```json
+ UserResponse(
+ user: User(
+ id: '11111111-1111-1111-1111-111111111111',
+ aud: 'authenticated',
+ role: 'authenticated',
+ email: '[email protected]',
+ emailConfirmedAt: '2024-01-01T00:00:00Z',
+ phone: '',
+ lastSignInAt: '2024-01-01T00:00:00Z',
+ appMetadata: {
+ 'provider': 'email',
+ 'providers': ['email']
+ },
+ userMetadata: {},
+ identities: [
+ UserIdentity(
+ identityId: '22222222-2222-2222-2222-222222222222',
+ id: '11111111-1111-1111-1111-111111111111',
+ userId: '11111111-1111-1111-1111-111111111111',
+ identityData: {
+ 'email': '[email protected]',
+ 'email_verified': false,
+ 'phone_verified': false,
+ 'sub': '11111111-1111-1111-1111-111111111111'
+ },
+ provider: 'email',
+ lastSignInAt: '2024-01-01T00:00:00Z',
+ createdAt: '2024-01-01T00:00:00Z',
+ updatedAt: '2024-01-01T00:00:00Z',
+ )
+ ],
+ createdAt: '2024-01-01T00:00:00Z',
+ updatedAt: '2024-01-01T00:00:00Z',
+ ),
+ );
+ ```
- id: generate-link
title: 'generateLink()'
notes: |
@@ -1350,6 +2308,51 @@ functions:
);
final actionLink = res.properties.actionLink;
```
+ response: |
+ ```json
+ GenerateLinkResponse(
+ properties: GenerateLinkProperties(
+ actionLink: '<LINK_TO_SEND_TO_USER>',
+ emailOtp: '999999',
+ hashedToken: '<HASHED_TOKEN',
+ redirectTo: '<REDIRECT_URL>',
+ verificationType: GenerateLinkType.signup
+ ),
+ user: User(
+ id: '11111111-1111-1111-1111-111111111111',
+ aud: 'authenticated',
+ role: 'authenticated',
+ email: '[email protected]',
+ emailConfirmedAt: '2024-01-01T00:00:00Z',
+ phone: '',
+ lastSignInAt: '2024-01-01T00:00:00Z',
+ appMetadata: {
+ 'provider': 'email',
+ 'providers': ['email']
+ },
+ userMetadata: {},
+ identities: [
+ UserIdentity(
+ identityId: '22222222-2222-2222-2222-222222222222',
+ id: '11111111-1111-1111-1111-111111111111',
+ userId: '11111111-1111-1111-1111-111111111111',
+ identityData: {
+ 'email': '[email protected]',
+ 'email_verified': false,
+ 'phone_verified': false,
+ 'sub': '11111111-1111-1111-1111-111111111111'
+ },
+ provider: 'email',
+ lastSignInAt: '2024-01-01T00:00:00Z',
+ createdAt: '2024-01-01T00:00:00Z',
+ updatedAt: '2024-01-01T00:00:00Z',
+ )
+ ],
+ createdAt: '2024-01-01T00:00:00Z',
+ updatedAt: '2024-01-01T00:00:00Z',
+ )
+ )
+ ```
- id: update-user-by-id
title: 'updateUserById()'
params:
@@ -1400,7 +2403,7 @@ functions:
isSpotlight: false
code: |
```dart
- final UserResponse res = await supabase.auth.admin.updateUserById(
+ await supabase.auth.admin.updateUserById(
'6aa5d0d4-2a9f-4483-b6c8-0cf4c6c98ac4',
attributes: AdminUserAttributes(
@@ -1493,6 +2496,36 @@ functions:
.from('cities')
.select('name');
```
+ 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
+ [
+ {
+ 'id': 1,
+ 'name': 'Afghanistan'
+ },
+ {
+ 'id': 2,
+ 'name': 'Albania'
+ },
+ {
+ 'id': 3,
+ 'name': 'Algeria'
+ },
+ ]
+ ```
- id: selecting-specific-columns
name: Selecting specific columns
description: You can select specific fields from your tables.
@@ -1507,6 +2540,33 @@ functions:
)
''');
```
+ 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
+ [
+ {
+ 'name': 'Afghanistan'
+ },
+ {
+ 'name': 'Albania'
+ },
+ {
+ 'name': 'Algeria'
+ },
+ ]
+ ```
- id: query-referenced-tables
name: Query referenced tables
description: If your database has relationships, you can query related tables too.
@@ -1520,19 +2580,145 @@ functions:
purchaser:purchaser_id ( name )
''');
```
- - id: query-the-same-referenced-table-multiple-times
- name: Query the same referenced table multiple times
- description: |
- Sometimes you will need to query the same referenced 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. This example queries a `messages` table that is
- joined to a `users` table via `sender_id` and `receiver_id`. Since you
- want the `name` for both sender and receiver, you can alias the
- columns as `to` and `from`.
- code: |
- ```dart
- final data = await supabase
+ 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
+ [
+ {
+ 'name': 'Germany',
+ 'cities': [
+ {
+ 'name': 'Munich'
+ },
+ ]
+ },
+ {
+ 'name': 'Indonesia',
+ 'cities': [
+ {
+ 'name': 'Bali'
+ },
+ ]
+ },
+ ]
+ ```
+ - id: query-referenced-tables-through-a-join-table
+ name: Query referenced tables through a join table
+ code: |
+ ```dart
+ final data = await supabase
+ .from('users')
+ .select('''
+ name,
+ teams (
+ 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,
+ -- 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: |
+ ```json
+ [
+ {
+ 'name': 'Kiran',
+ 'teams': [
+ {
+ 'name': 'Green'
+ },
+ {
+ 'name': 'Blue'
+ },
+ ]
+ },
+ {
+ 'name': 'Evan',
+ 'teams': [
+ {
+ 'name': 'Blue'
+ }
+ ]
+ }
+ ]
+ ```
+ 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.
+ hideCodeBlock: true
+ - id: query-the-same-referenced-table-multiple-times
+ name: Query the same referenced table multiple times
+ description: |
+ Sometimes you will need to query the same referenced 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. This example queries a `messages` table that is
+ joined to a `users` table via `sender_id` and `receiver_id`. Since you
+ want the `name` for both sender and receiver, you can alias the
+ columns as `to` and `from`.
+ code: |
+ ```dart
+ final data = await supabase
.from('messages')
.select('''
content,
@@ -1540,18 +2726,94 @@ functions:
to:receiver_id(name)
''');
```
- - id: filtering-with-inner-joins
- name: Filtering with inner joins
- description: |
- If you want to filter a table based on a child table's values you can use the `!inner()` function. For example, if you wanted
- to select all rows in a `message` table which belong to a user with the `username` "Jane":
+ data:
+ sql: |
+ ```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, 'πŸ‘‹');
+ ```
+ response: |
+ ```json
+ [
+ {
+ 'content': 'πŸ‘‹',
+ 'from': {
+ 'name': 'Kiran'
+ },
+ 'to': {
+ 'name': 'Evan'
+ }
+ }
+ ]
+ ```
+ - id: filtering-through-referenced-tables
+ name: Filtering through referenced tables
code: |
```dart
final data = await supabase
- .from('messages')
- .select('*, users!inner(*)')
- .eq('users.username', 'Jane');
+ .from('cities')
+ .select('name, countries(*)')
+ .eq('countries.name', 'Estonia');
+ ```
+ 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
+ [
+ {
+ 'name': 'Bali',
+ 'countries': null
+ },
+ {
+ 'name': 'Munich',
+ 'countries': null
+ }
+ ]
```
+ 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.
+ If you want to filter out the parent table rows, use the `!inner` hint
+ hideCodeBlock: true
- id: querying-with-count-option
name: Querying with count option
description: |
@@ -1567,6 +2829,39 @@ functions:
final data = res.data;
final count = res.count;
```
+ 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
+ PostgrestResponse(
+ data: [
+ {
+ 'id': 1,
+ 'name': 'Afghanistan'
+ },
+ {
+ 'id': 2,
+ 'name': 'Albania'
+ },
+ {
+ 'id': 3,
+ 'name': 'Algeria'
+ }
+ ],
+ count: 3
+ );
+ ```
- id: querying-json-data
name: Querying JSON data
description: |
@@ -1581,22 +2876,114 @@ functions:
.from('users')
.select('''
id, name,
- address->street
- ''')
- .eq('address->postcode', 90210);
+ address->city
+ ''');
+ ```
+ data:
+ sql: |
+ ```sql
+ create table
+ users (
+ id int8 primary key,
+ name text,
+ address jsonb
+ );
+
+ insert into
+ users (id, name, address)
+ values
+ (1, 'Avdotya', '{"city":"Saint Petersburg"}');
+ ```
+ response: |
+ ```json
+ [
+ {
+ 'id': 1,
+ 'name': 'Avdotya',
+ 'city': 'Saint Petersburg'
+ }
+ ]
+ ```
+ - id: querying-referenced-table-with-inner-join
+ name: Querying referenced table with inner join
+ code: |
+ ```dart
+ final data = await supabase
+ .from('cities')
+ .select('name, countries!inner(name)')
+ .eq('countries.name', 'Indonesia');
+ ```
+ data:
+ sql: |
+ ```sql
+ create table countries (
+ "id" "uuid" primary key default "extensions"."uuid_generate_v4"() not null,
+ "name" text
+ );
+
+ create table cities (
+ "id" "uuid" primary key default "extensions"."uuid_generate_v4"() not null,
+ "name" text,
+ "country_id" "uuid" references public.countries on delete cascade
+ );
+
+ with country as (
+ insert into countries (name)
+ values ('united kingdom') returning id
+ )
+ insert into cities (name, country_id) values
+ ('London', (select id from country)),
+ ('Manchester', (select id from country)),
+ ('Liverpool', (select id from country)),
+ ('Bristol', (select id from country));
+ ```
+ response: |
+ ```json
+ [
+ {
+ 'name': 'Bali',
+ 'countries': {'name': 'Indonesia'}
+ }
+ ]
```
- - id: return-data-as-csv
- name: Return data as CSV
description: |
- By default the data is returned in JSON format, however you can also request for it to be returned as Comma Separated Values.
+ If you don't want to return the referenced table contents, you can leave the parenthesis empty.
+ Like `.select('name, countries!inner()')`.
+ hideCodeBlock: true
+ - id: switching-schemas-per-query
+ name: Switching schemas per query
code: |
```dart
final data = await supabase
- .from('users')
- .select()
- .csv();
+ .schema('myschema')
+ .from('mytable')
+ .select();
```
+ data:
+ sql: |
+ ```sql
+ create schema myschema;
+
+ create table myschema.mytable (
+ id uuid primary key default gen_random_uuid(),
+ data text
+ );
+ insert into myschema.mytable (data) values ('mydata');
+ ```
+ response: |
+ ```json
+ [
+ {
+ 'id': '4162e008-27b0-4c0f-82dc-ccaeee9a624d',
+ 'data': 'mydata'
+ }
+ ]
+ ```
+ description: |
+ In addition to setting the schema during initialization, you can also switch schemas on a per-query basis.
+ Make sure you've set up your [database privileges and API settings](/docs/guides/api/using-custom-schemas).
+ hideCodeBlock: true
- id: insert
description: |
Perform an INSERT into the table or view.
@@ -1616,15 +3003,13 @@ functions:
.from('cities')
.insert({'name': 'The Shire', 'country_id': 554});
```
- - id: bulk-create
- name: Bulk create
- code: |
- ```dart
- await supabase.from('cities').insert([
- {'name': 'The Shire', 'country_id': 554},
- {'name': 'Rohan', 'country_id': 555},
- ]);
- ```
+ data:
+ sql: |
+ ```sql
+ create table
+ countries (id int8 primary key, name text);
+ ```
+ hideCodeBlock: true
- id: fetch-inserted-data
name: Fetch inserted record
code: |
@@ -1635,8 +3020,47 @@ functions:
{'name': 'Rohan', 'country_id': 555},
]).select();
```
-
- - id: update
+ data:
+ sql: |
+ ```sql
+ create table
+ countries (id int8 primary key, name text);
+ ```
+ response: |
+ ```json
+ [
+ {
+ 'id': 1,
+ 'name': 'Denmark'
+ }
+ ]
+ ```
+ - id: bulk-create
+ name: Bulk create
+ code: |
+ ```dart
+ await supabase.from('cities').insert([
+ {'name': 'The Shire', 'country_id': 554},
+ {'name': 'Rohan', 'country_id': 555},
+ ]);
+ ```
+ data:
+ sql: |
+ ```sql
+ create table
+ countries (id int8 primary key, name text);
+ ```
+ response: |
+ ```json
+ PostgrestException(
+ 'code': '23505',
+ 'details': 'Key (id)=(1) already exists.',
+ 'hint': null,
+ 'message': 'duplicate key value violates unique constraint "countries_pkey"'
+ );
+ ```
+
+ - id: update
description: |
Perform an UPDATE on the table or view.
title: 'Modify data: update()'
@@ -1654,17 +3078,54 @@ functions:
code: |
```dart
await supabase
- .from('cities')
- .update({ 'name': 'Middle Earth' })
- .match({ 'name': 'Auckland' });
+ .from('countries')
+ .update({ 'name': 'Australia' })
+ .eq('id', 1);
```
+ data:
+ sql: |
+ ```sql
+ create table
+ countries (id int8 primary key, name text);
+
+ insert into
+ countries (id, name)
+ values
+ (1, 'Taiwan');
+ ```
+ - id: update-a-record-and-return-it
+ name: Update a record and return it
+ code: |
+ ```dart
+ final data = await supabase
+ .from('countries')
+ .update({ 'name': 'Australia' })
+ .eq('id', 1)
+ .select();
+ ```
+ data:
+ sql: |
+ ```sql
+ create table
+ countries (id int8 primary key, name text);
+
+ insert into
+ countries (id, name)
+ values
+ (1, 'Taiwan');
+ ```
+ response: |
+ ```json
+ [
+ {
+ 'id': 1,
+ 'name': 'Australia'
+ }
+ ]
+ ```
+ hideCodeBlock: true
- id: updating-json-data
name: Update 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: |
```dart
await supabase
@@ -1677,18 +3138,38 @@ functions:
})
.eq('address->postcode', 90210);
```
- - id: fetch-updated-rows
- name: Fetch updated rows
- code: |
- ```dart
- final List<Map<String, dynamic>> data = await supabase
- .from('users')
- .update({
- 'address': {'street': 'Melrose Place', 'postcode': 90210}
- })
- .eq('address->postcode', 90210)
- .select();
+ 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 }');
+ ```
+ response: |
+ ```json
+ [
+ {
+ 'id': 1,
+ 'name': 'Michael',
+ 'address': {
+ 'street': 'Melrose Place',
+ 'postcode': 90210
+ }
+ }
+ ]
```
+ description: |
+ Postgres offers some
+ [operators](/docs/guides/database/json#query-the-jsonb-data) for
+ working with JSON data. Currently, it is only possible to update the entire JSON document.
- id: upsert
description: |
@@ -1719,38 +3200,109 @@ functions:
isSpotlight: true
code: |
```dart
- await supabase
- .from('messages')
- .upsert({ 'id': 3, 'message': 'foo', 'username': 'supabot' });
+ final data = await supabase
+ .from('countries')
+ .upsert({ 'id': 1, 'name': 'Albania' })
+ .select();
+ ```
+ data:
+ sql: |
+ ```sql
+ create table
+ countries (id int8 primary key, name text);
+
+ insert into
+ countries (id, name)
+ values
+ (1, 'Afghanistan');
+ ```
+ response: |
+ ```json
+ [
+ {
+ 'id': 1,
+ 'name': 'Albania'
+ }
+ ]
```
+ - id: bulk-upsert-your-data
+ name: Bulk Upsert your data
+ code: |
+ ```dart
+ final data = await supabase
+ .from('countries')
+ .upsert([
+ { 'id': 1, 'name': 'Albania' },
+ { 'id': 2, 'name': 'Algeria' },
+ ])
+ .select();
+ ```
+ data:
+ sql: |
+ ```sql
+ create table
+ countries (id int8 primary key, name text);
+
+ insert into
+ countries (id, name)
+ values
+ (1, 'Afghanistan');
+ ```
+ response: |
+ ```json
+ [
+ {
+ 'id': 1,
+ 'name': 'Albania'
+ },
+ {
+ 'id': 2,
+ 'name': 'Algeria'
+ }
+ ]
+ ```
+ hideCodeBlock: true
- 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: |
```dart
- await supabase
+ final data = await supabase
.from('users')
- .upsert({ 'username': 'supabot' }, onConflict: 'username');
+ .upsert({ 'id': 42, 'handle': 'saoirse', 'display_name': 'Saoirse' }, { onConflict: 'handle' })
+ .select();
```
- - id: return-the-exact-number-of-rows
- name: Return the exact number of rows
- description: |
- Allowed values for count option are `CountOption.exact`, `CountOption.planned` and `CountOption.estimated`.
- code: |
- ```dart
- final res = await supabase.from('users').upsert({
- 'id': 3,
- 'message': 'foo',
- 'username': 'supabot'
- }).count(CountOption.exact);
+ data:
+ sql: |
+ ```sql
+ create table
+ users (
+ id int8 generated by default as identity primary key,
+ handle text not null unique,
+ display_name text
+ );
- final data = res.data;
- final count = res.count;
+ insert into
+ users (id, handle, display_name)
+ values
+ (1, 'saoirse', null);
+ ```
+ response: |
+ ```json
+ PostgrestException(
+ 'code': '23505',
+ 'details': 'Key (handle)=(saoirse) already exists.',
+ 'hint': null,
+ 'message': "duplicate key value violates unique constraint "users_handle_key"'
+ )
```
+ description: |
+ In the above 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"`.
+ Using the `onConflict` option, you can instruct `upsert()` to use
+ another column with a unique constraint to determine conflicts.
- id: delete
description: |
@@ -1766,10 +3318,41 @@ functions:
code: |
```dart
await supabase
- .from('cities')
+ .from('countries')
+ .delete()
+ .eq('id', 1);
+ ```
+ data:
+ sql: |
+ ```sql
+ create table
+ countries (id int8 primary key, name text);
+
+ insert into
+ countries (id, name)
+ values
+ (1, 'Spain');
+ ```
+ - id: delete-multiple-records
+ name: Delete multiple records
+ code: |
+ ```dart
+ await supabase
+ .from('countries')
.delete()
- .match({ 'id': 666 });
+ .inFilter('id', [1, 2, 3])
```
+ data:
+ sql: |
+ ```sql
+ create table
+ countries (id int8 primary key, name text);
+
+ insert into
+ countries (id, name)
+ values
+ (1, 'Spain'), (2, 'France'), (3, 'Germany');
+ ```
- id: fetch-delete-records
name: Fetch deleted records
code: |
@@ -1814,11 +3397,7 @@ functions:
```
response: |
```json
- {
- "data": "Hello world",
- "status": 200,
- "statusText": "OK"
- }
+ 'Hello world'
```
hideCodeBlock: true
isSpotlight: true
@@ -1838,12 +3417,8 @@ functions:
```
response: |
```json
- {
- "data": "πŸ‘‹",
- "status": 200,
- "statusText": "OK"
- }
- ```
+ 'πŸ‘‹'
+ ```
hideCodeBlock: true
- id: bulk-processing
name: Bulk processing
@@ -1861,15 +3436,11 @@ functions:
```
response: |
```json
- {
- "data": [
- 2,
- 3,
- 4
- ],
- "status": 200,
- "statusText": "OK"
- }
+ [
+ 2,
+ 3,
+ 4,
+ ]
```
description: |
You can process large payloads by passing in an array as an argument.
@@ -1902,12 +3473,8 @@ functions:
response: |
```json
{
- "data": {
- "id": 1,
- "name": "France"
- },
- "status": 200,
- "statusText": "OK"
+ 'id': 1,
+ 'name': 'France'
}
```
description: |
@@ -2960,41 +4527,40 @@ functions:
queries that return rows (e.g., `select()` or `rpc()` on a function that
returns a table response).
- - id: limit
- title: limit()
- description: |
- Limits the result with the specified count.
- params:
- - name: count
- isOptional: false
- type: int
- description: The maximum number of rows to return.
- - name: referencedTable
- isOptional: true
- type: int
- description: Set this to limit rows of referenced tables instead of the parent table.
+ - id: db-modifiers-select
+ title: select()
examples:
- - id: with-select
- name: With `select()`
- isSpotlight: true
- code: |
- ```dart
- final data = await supabase
- .from('cities')
- .select('name, country_id')
- .limit(1);
- ```
- - id: with-embedded-resources
- name: With embedded resources
+ - id: with-upsert
+ name: With `upsert()`
code: |
```dart
final data = await supabase
.from('countries')
- .select('name, cities(name)')
- .eq('name', 'United States')
- .limit(1, referencedTable: 'cities' );
+ .upsert({ 'id': 1, 'name': 'Algeria' })
+ .select();
```
+ data:
+ sql: |
+ ```sql
+ create table
+ countries (id int8 primary key, name text);
+ insert into
+ countries (id, name)
+ values
+ (1, 'Afghanistan');
+ ```
+ response: |
+ ```json
+ [
+ {
+ "id": 1,
+ "name": "Algeria"
+ }
+ ]
+ ```
+ hideCodeBlock: true
+ isSpotlight: true
- id: order
title: order()
description: |
@@ -3016,6 +4582,117 @@ functions:
isOptional: true
type: String
description: Specify the referenced table when ordering by a column in an embedded resource.
+ examples:
+ - id: with-select
+ name: With `select()`
+ isSpotlight: true
+ code: |
+ ```dart
+ final data = await supabase
+ .from('countries')
+ .select('id, name')
+ .order('id', ascending: false);
+ ```
+ 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
+ [
+ {
+ 'id': 3,
+ 'name': 'Algeria'
+ },
+ {
+ 'id': 2,
+ 'name': 'Albania'
+ },
+ {
+ 'id': 1,
+ 'name': 'Afghanistan'
+ }
+ ]
+ ```
+ - id: on-a-referenced-table
+ name: On a referenced table
+ code: |
+ ```dart
+ final data = await supabase
+ .from('countries')
+ .select('''
+ name,
+ cities (
+ name
+ )
+ ''')
+ .order('name', referencedTable: 'cities', ascending: false);
+ ```
+ 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
+ [
+ {
+ 'name': 'United States',
+ 'cities': [
+ {
+ 'name': 'New York City'
+ },
+ {
+ 'name': 'Atlanta'
+ }
+ ]
+ },
+ {
+ 'name': 'Vanuatu',
+ 'cities': []
+ }
+ ]
+ ```
+ - id: limit
+ title: limit()
+ description: |
+ Limits the result with the specified count.
+ params:
+ - name: count
+ isOptional: false
+ type: int
+ description: The maximum number of rows to return.
+ - name: referencedTable
+ isOptional: true
+ type: int
+ description: Set this to limit rows of referenced tables instead of the parent table.
examples:
- id: with-select
name: With `select()`
@@ -3024,20 +4701,79 @@ functions:
```dart
final data = await supabase
.from('cities')
- .select('name, country_id')
- .order('id', ascending: true);
+ .select('name')
+ .limit(1);
+ ```
+ 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
+ [
+ {
+ 'name': 'Afghanistan'
+ }
+ ]
```
- - id: with-embedded-resources
- name: With embedded resources
+ - id: on-a-referenced-table
+ name: On a referenced table
code: |
```dart
final data = await supabase
.from('countries')
- .select('name, cities(name)')
- .eq('name', 'United States')
- .order('name', referencedTable: 'cities');
+ .select('''
+ name,
+ cities (
+ name
+ )
+ ''')
+ .limit(1, referencedTable: 'cities');
```
+ 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
+ [
+ {
+ 'name': 'United States',
+ 'cities': [
+ {
+ 'name': 'Atlanta'
+ }
+ ]
+ }
+ ]
+ ```
- id: range
title: range()
description: |
@@ -3062,38 +4798,112 @@ functions:
code: |
```dart
final data = await supabase
- .from('cities')
- .select('name, country_id')
- .range(0,3);
+ .from('countries')
+ .select('name')
+ .range(0, 1);
+ ```
+ 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
+ [
+ {
+ 'name': 'Afghanistan'
+ },
+ {
+ 'name': 'Albania'
+ }
+ ]
+ ```
+ - id: single
+ title: single()
+ description: |
+ Retrieves only one row from the result. Result must be one row (e.g. using limit), otherwise this will result in an error.
+ examples:
+ - id: with-select
+ name: With `select()`
+ isSpotlight: true
+ code: |
+ ```dart
+ final data = await supabase
+ .from('countries')
+ .select('name')
+ .limit(1)
+ .single();
+ ```
+ 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
+ {
+ 'name': 'Afghanistan'
+ }
+ ```
+ - id: maybe-single
+ title: maybeSingle()
+ examples:
+ - id: with-select
+ name: With `select()`
+ code: |
+ ```dart
+ final data = await supabase
+ .from('countries')
+ .select()
+ .eq('name', 'Singapore')
+ .maybeSingle();
+ ```
+ 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
+ null
```
-
- - id: single
- title: single()
- description: |
- Retrieves only one row from the result. Result must be one row (e.g. using limit), otherwise this will result in an error.
- examples:
- - id: with-select
- name: With `select()`
+ hideCodeBlock: true
isSpotlight: true
- code: |
- ```dart
- final data = await supabase
- .from('cities')
- .select('name, country_id')
- .single();
- ```
- - id: maybe-single
- title: maybeSingle()
+ - id: csv
+ title: csv()
examples:
- - id: with-select
- name: With `select()`
+ - id: return-data-as-csv
+ name: Return data as CSV
code: |
```dart
final data = await supabase
.from('countries')
.select()
- .eq('name', 'Singapore')
- .maybeSingle();
+ .csv();
```
data:
sql: |
@@ -3110,8 +4920,10 @@ functions:
```
response: |
```json
- null
+ 'id,name\n1,Afghanistan\n1,Albania\n1,Algeria'
```
+ description: |
+ By default, the data is returned in JSON format, but can also be returned as Comma Separated Values.
hideCodeBlock: true
isSpotlight: true
- id: explain
@@ -3298,12 +5110,12 @@ functions:
```json
[
{
- "id": 1,
- "name": "Michael",
- "address": {
- "postcode": 90210
+ 'id': 1,
+ 'name': 'Michael',
+ 'address': {
+ 'postcode': 90210
}
- }
+ },
]
```
code: |
@@ -3351,18 +5163,18 @@ functions:
(2, 1, 'Munich');
```
response: |
- ```json
- [
- {
- "name": "Indonesia",
- "cities": [
- {
- "name": "Bali"
- }
- ]
- }
- ]
- ```
+ ```json
+ [
+ {
+ 'name': 'Indonesia',
+ 'cities': [
+ {
+ 'name': 'Bali'
+ }
+ ]
+ },
+ ]
+ ```
description: |
You can filter on referenced tables in your `select()` query using dot
notation.
@@ -3394,18 +5206,63 @@ functions:
code: |
```dart
final data = await supabase
- .from('cities')
- .select('name, country_id')
- .or('id.eq.20,id.eq.30');
+ .from('countries')
+ .select('name')
+ .or('id.eq.2,name.eq.Algeria');
+ ```
+ 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
+ [
+ {
+ 'name': 'Albania'
+ },
+ {
+ 'name': 'Algeria'
+ }
+ ]
```
- id: use-or-with-and
name: Use `or` with `and`
code: |
```dart
final data = await supabase
- .from('cities')
- .select('name, country_id')
- .or('id.gt.20,and(name.eq.New Zealand,name.eq.France)');
+ .from('countries')
+ .select('name')
+ .or('id.gt.3,and(id.eq.1,name.eq.Afghanistan)');
+ ```
+ data:
+ sql: |
+ ```sql
+ create table
+ countries (id int8 primary key, name text);
+
+ insert into
+ countries (id, name)
+ values
+ (1, 'Afghanistan'),
+ (2, 'Albania'),
+ (3, 'Algeria');
+ ```
+ reponse: |
+ ```json
+ [
+ {
+ 'name': 'Afghanistan'
+ }
+ ]
```
- id: use-or-on-referenced-tables
name: Use `or` on referenced tables
@@ -3413,8 +5270,13 @@ functions:
```dart
final data = await supabase
.from('countries')
- .select('name, cities!inner(name)')
- .or('country_id.eq.1,name.eq.Beijing', referencedTable: 'cities');
+ .select('''
+ name,
+ cities!inner (
+ name
+ )
+ ''')
+ .or('country_id.eq.1,name.eq.Beijing', referencedTable: 'cities' );
```
data:
sql: |
@@ -3443,10 +5305,10 @@ functions:
```json
[
{
- "name": "Germany",
- "cities": [
+ 'name': 'Germany',
+ 'cities': [
{
- "name": "Munich"
+ 'name': 'Munich'
}
]
}
@@ -3488,9 +5350,30 @@ functions:
code: |
```dart
final data = await supabase
- .from('cities')
- .select('name, country_id')
- .not('name', 'eq', 'Paris');
+ .from('countries')
+ .select()
+ .not('name', 'is', null)
+ ```
+ data:
+ sql: |
+ ```sql
+ create table
+ countries (id int8 primary key, name text);
+
+ insert into
+ countries (id, name)
+ values
+ (1, 'null'),
+ (2, null);
+ ```
+ response: |
+ ```json
+ [
+ {
+ 'id': 1,
+ 'name': 'null'
+ }
+ ]
```
- id: with-update
name: With `update()`
@@ -3556,7 +5439,7 @@ functions:
```json
[
{
- "name": "Albania"
+ 'name': 'Albania'
}
]
```
@@ -3603,9 +5486,9 @@ functions:
```json
[
{
- "id": 2,
- "name": "Albania"
- }
+ 'id': 2,
+ 'name': 'Albania'
+ },
]
```
hideCodeBlock: true
@@ -3651,13 +5534,13 @@ functions:
```json
[
{
- "id": 1,
- "name": "Afghanistan"
+ 'id': 1,
+ 'name': 'Afghanistan'
},
{
- "id": 3,
- "name": "Algeria"
- }
+ 'id': 3,
+ 'name': 'Algeria'
+ },
]
```
hideCodeBlock: true
@@ -3703,9 +5586,9 @@ functions:
```json
[
{
- "id": 3,
- "name": "Algeria"
- }
+ 'id': 3,
+ 'name': 'Algeria'
+ },
]
```
hideCodeBlock: true
@@ -3751,13 +5634,13 @@ functions:
```json
[
{
- "id": 2,
- "name": "Albania"
+ 'id': 2,
+ 'name': 'Albania'
},
{
- "id": 3,
- "name": "Algeria"
- }
+ 'id': 3,
+ 'name': 'Algeria'
+ },
]
```
hideCodeBlock: true
@@ -3803,9 +5686,9 @@ functions:
```json
[
{
- "id": 1,
- "name": "Afghanistan"
- }
+ 'id': 1,
+ 'name': 'Afghanistan'
+ },
]
```
hideCodeBlock: true
@@ -3851,13 +5734,13 @@ functions:
```json
[
{
- "id": 1,
- "name": "Afghanistan"
+ 'id': 1,
+ 'name': 'Afghanistan'
},
{
- "id": 2,
- "name": "Albania"
- }
+ 'id': 2,
+ 'name': 'Albania'
+ },
]
```
hideCodeBlock: true
@@ -3903,9 +5786,9 @@ functions:
```json
[
{
- "id": 2,
- "name": "Albania"
- }
+ 'id': 2,
+ 'name': 'Albania'
+ },
]
```
hideCodeBlock: true
@@ -3947,15 +5830,15 @@ functions:
(2, 'Albania'),
(3, 'Algeria');
```
- response: |
- ```json
- [
- {
- "id": 2,
- "name": "Albania"
- }
- ]
- ```
+ response: |
+ ```json
+ [
+ {
+ 'id': 2,
+ 'name': 'Albania'
+ },
+ ]
+ ```
hideCodeBlock: true
isSpotlight: true
@@ -3998,9 +5881,9 @@ functions:
```json
[
{
- "id": 1,
- "name": "null"
- }
+ 'id': 1,
+ 'name': 'null'
+ },
]
```
description: |
@@ -4052,13 +5935,13 @@ functions:
```json
[
{
- "id": 2,
- "name": "Albania"
+ 'id': 2,
+ 'name': 'Albania'
},
{
- "id": 3,
- "name": "Algeria"
- }
+ 'id': 3,
+ 'name': 'Algeria'
+ },
]
```
description: |
@@ -4111,10 +5994,10 @@ functions:
```json
[
{
- "id": 1,
- "title": "Cache invalidation is not working",
- "tags": ["is:open", "severity:high", "priority:low"]
- }
+ 'id': 1,
+ 'title': 'Cache invalidation is not working',
+ 'tags': ['is:open', 'severity:high', 'priority:low']
+ },
]
```
hideCodeBlock: true
@@ -4147,10 +6030,10 @@ functions:
```json
[
{
- "id": 1,
- "room_name": "Emerald",
- "during": "[\"2000-01-01 13:00:00\",\"2000-01-01 15:00:00\")"
- }
+ 'id': 1,
+ 'room_name': 'Emerald',
+ 'during': '["2000-01-01 13:00:00","2000-01-01 15:00:00")'
+ },
]
```
description: |
@@ -4188,8 +6071,8 @@ functions:
```json
[
{
- "name": "Michael"
- }
+ 'name': 'Michael'
+ },
]
```
hideCodeBlock: true
@@ -4238,8 +6121,8 @@ functions:
```json
[
{
- "name": "Chemistry"
- }
+ 'name': 'Chemistry'
+ },
]
```
hideCodeBlock: true
@@ -4272,10 +6155,10 @@ functions:
```json
[
{
- "id": 1,
- "room_name": "Emerald",
- "during": "[\"2000-01-01 13:00:00\",\"2000-01-01 15:00:00\")"
- }
+ 'id': 1,
+ 'room_name': 'Emerald',
+ 'during': '["2000-01-01 13:00:00","2000-01-01 15:00:00")'
+ },
]
```
description: |
@@ -4313,8 +6196,8 @@ functions:
```json
[
{
- "name": "Jane"
- }
+ 'name': 'Jane'
+ },
]
```
hideCodeBlock: true
@@ -4362,10 +6245,10 @@ functions:
```json
[
{
- "id": 1,
- "room_name": "Emerald",
- "during": "[\"2000-01-01 13:00:00\",\"2000-01-01 15:00:00\")"
- }
+ 'id': 1,
+ 'room_name': 'Emerald',
+ 'during': '["2000-01-01 13:00:00","2000-01-01 15:00:00")'
+ },
]
```
description: |
@@ -4417,14 +6300,14 @@ functions:
```
response: |
```json
- [
- {
- "id": 2,
- "room_name": "Topaz",
- "during": "[\"2000-01-02 09:00:00\",\"2000-01-02 10:00:00\")"
- }
- ]
- ```
+ [
+ {
+ 'id': 2,
+ 'room_name': 'Topaz',
+ 'during': '["2000-01-02 09:00:00","2000-01-02 10:00:00")'
+ }
+ ]
+ ```
description: |
Postgres supports a number of [range
types](https://www.postgresql.org/docs/current/rangetypes.html). You
@@ -4474,14 +6357,14 @@ functions:
```
response: |
```json
- [
- {
- "id": 2,
- "room_name": "Topaz",
- "during": "[\"2000-01-02 09:00:00\",\"2000-01-02 10:00:00\")"
- }
- ]
- ```
+ [
+ {
+ 'id': 2,
+ 'room_name': 'Topaz',
+ 'during': '["2000-01-02 09:00:00","2000-01-02 10:00:00")''
+ },
+ ]
+ ```
description: |
Postgres supports a number of [range
types](https://www.postgresql.org/docs/current/rangetypes.html). You
@@ -4533,10 +6416,10 @@ functions:
```json
[
{
- "id": 1,
- "room_name": "Emerald",
- "during": "[\"2000-01-01 13:00:00\",\"2000-01-01 15:00:00\")"
- }
+ 'id': 1,
+ 'room_name': 'Emerald',
+ 'during': '["2000-01-01 13:00:00","2000-01-01 15:00:00")'
+ },
]
```
description: |
@@ -4590,10 +6473,10 @@ functions:
```json
[
{
- "id": 1,
- "room_name": "Emerald",
- "during": "[\"2000-01-01 13:00:00\",\"2000-01-01 15:00:00\")"
- }
+ 'id': 1,
+ 'room_name': 'Emerald',
+ 'during': '["2000-01-01 13:00:00","2000-01-01 15:00:00")'
+ },
]
```
description: |
@@ -4647,8 +6530,8 @@ functions:
```json
[
{
- "title": "Cache invalidation is not working"
- }
+ 'title': 'Cache invalidation is not working'
+ },
]
```
hideCodeBlock: true
@@ -4682,10 +6565,10 @@ functions:
```json
[
{
- "id": 1,
- "room_name": "Emerald",
- "during": "[\"2000-01-01 13:00:00\",\"2000-01-01 15:00:00\")"
- }
+ 'id': 1,
+ 'room_name': 'Emerald',
+ 'during': '["2000-01-01 13:00:00","2000-01-01 15:00:00")'
+ },
]
```
description: |
@@ -4724,10 +6607,34 @@ functions:
final data = await supabase
.from('quotes')
.select('catchphrase')
- .textSearch('catchphrase', "'fat' & 'cat'",
+ .textSearch('content', "'eggs' & 'ham'",
config: 'english'
);
```
+ data:
+ sql: |
+ ```sql
+ create table texts (
+ id bigint
+ primary key
+ generated always as identity,
+ content text
+ );
+
+ insert into texts (content) values
+ ('Four score and seven years ago'),
+ ('The road goes ever on and on'),
+ ('Green eggs and ham')
+ ;
+ ```
+ response: |
+ ```json
+ [
+ {
+ 'content': 'Green eggs and ham'
+ }
+ ]
+ ```
- id: basic-normalization
name: Basic normalization
description: Uses PostgreSQL's `plainto_tsquery` function.
@@ -4809,9 +6716,31 @@ functions:
code: |
```dart
final data = await supabase
- .from('cities')
- .select('name, country_id')
- .filter('name', 'in', '("Paris","Tokyo")');
+ .from('countries')
+ .select()
+ .filter('name', 'in', '("Algeria","Japan")')
+ ```
+ 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
+ [
+ {
+ 'id': 3,
+ 'name': 'Algeria'
+ }
+ ]
```
- id: with-update
name: With `update()`
@@ -4846,8 +6775,13 @@ functions:
```dart
final data = await supabase
.from('countries')
- .select('name, countries!inner( name )')
- .filter('cities.name', 'eq', 'Bali');
+ .select('''
+ name,
+ cities!inner (
+ name
+ )
+ ''')
+ .filter('cities.name', 'eq', 'Bali')
```
data:
sql: |
@@ -4876,10 +6810,10 @@ functions:
```json
[
{
- "name": "Indonesia",
- "cities": [
+ 'name': 'Indonesia',
+ 'cities': [
{
- "name": "Bali"
+ 'name': 'Bali'
}
]
}